Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parseFromUrl return tokens in hash, also include state #311

Merged
merged 1 commit into from
Jan 22, 2020

Conversation

aarongranick-okta
Copy link
Contributor

Changes behavior on parseFromUrl

Previously:

  • tokens were returned in an array, in the same order as specified in responseTypes
  • If responseTypes was not an array, the token object was returned

Now:

  • An object is always returned. It will contain two properties
    • state which contains the value passed to getWithRedirect (or any of the other getToken calls) This allows passing information to the callback handler.
    • tokens which contains a hash of tokens returned. Possible key values are idToken and accessToken
  • Token objects have a field value which contains the raw token string. For an ID token this is the same as the idToken field, for an access token it is the same as the accessToken field.

@@ -1616,8 +1628,15 @@ The ID token will be [verified and validated](https://github.com/okta/okta-auth-

```javascript
authClient.token.parseFromUrl()
.then(function(tokenOrTokens) {
.then(function(res) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

res implies an HTTP Response object, is there a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an object which contains a tokens hash and a state string.

@@ -266,32 +272,28 @@ function handleOAuthResponse(sdk, oauthParams, res, urls) {

return verifyToken(sdk, idToken, validationParams)
.then(function() {
tokenDict['id_token'] = idToken;
tokenDict['idToken'] = idToken;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why not dot notation?

Comment on lines +239 to 242
value: res['access_token'],
accessToken: res['access_token'],
expiresAt: Number(res['expires_in']) + Math.floor(Date.now()/1000),
tokenType: res['token_type'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why not dot notation for all of these? (underscore isn't a problem, just '-')

@aarongranick-okta aarongranick-okta force-pushed the ag-tokens-format-OKTA-106993 branch from 474441f to 9288398 Compare January 22, 2020 21:44
@aarongranick-okta aarongranick-okta merged commit 2b949de into v3.0 Jan 22, 2020
@aarongranick-okta aarongranick-okta deleted the ag-tokens-format-OKTA-106993 branch January 22, 2020 23:43
@aarongranick-okta aarongranick-okta mentioned this pull request Jan 31, 2020
@aarongranick-okta aarongranick-okta mentioned this pull request Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants