paulvanbladel / aurelia-auth

:key: Authentication plugin for aurelia
200 stars 74 forks source link

Using the accessToken #119

Closed dmason511 closed 8 years ago

dmason511 commented 8 years ago

I am requesting a response type of 'id_token token' from IdentityServerv3 and getting the expected id_token and access_token. I am successfully storing the id_token in localStorage but the access_token is not. I found the section in the authentication.js file that addresses the accessToken but was unable to find anywhere that it actually stores the token.

Authentication.prototype.setToken = function setToken(response, redirect) { var accessToken = response && response[this.config.responseTokenProp]; var tokenToStore = void 0;

  if (accessToken) {
    if ((0, _authUtilities.isObject)(accessToken) && (0, _authUtilities.isObject)(accessToken.data)) {
      response = accessToken;
    } else if ((0, _authUtilities.isString)(accessToken)) {
      tokenToStore = accessToken;
    }
  }

The idToken has a section that does this if (idToken) { this.storage.set(this.idTokenName, idToken); }

How do I store the accesstoken in localStorage? How can I pass the accesstoken instead of the idToken to my WebApi? Are both the storage question and accessToken configurable via authconfig file?

Thanks, DM

dmason511 commented 8 years ago

Found it. tokenName : 'access_token', instead of 'id_token' in authConfig file.

paulvanbladel commented 8 years ago

Sorry I missed you initial question. Glad you solved it.