-
Notifications
You must be signed in to change notification settings - Fork 232
Handle errors during token renewal. Expose TokenManager [react, angular, vue] #551
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline comments
a4b3a51
to
8db37dd
Compare
f5dabb9
to
43517ea
Compare
packages/okta-angular/README.md
Outdated
@@ -94,6 +94,10 @@ For PKCE flow, this should be left undefined or set to `['code']`. | |||
- `autoRenew` *(optional)*: | |||
By default, the library will attempt to renew expired tokens. When an expired token is requested by the library, a renewal request is executed to update the token. If you wish to to disable auto renewal of tokens, set autoRenew to false. | |||
|
|||
- `onTokenError` *(optional)* - callback function. If there is an error while renewing a token, the error will be passed to a handler function. The default handler calls `loginRedirect()` to initiate a login flow. Passing a function here will override the default handler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an error in renewing (onRenewError()
?) or an error with the token (and/or getting it) in general? If the latter, the documentation does not match that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an error emitted from the TokenManager. Currently, Renew is the only case where this error will be emitted. Would onTokenManagerError
be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's for all errors and the renew is all that we have now, that's fine as is, I just couldn't tell if we expected future errors from the token manager to come through this callback from the text, so I wanted to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could instead have a callback ONLY for the "login_required" error code. (One could still getTokenManager().on('error', ...
to listen for other errors should they ever exist) This would be almost identical in purpose to the existing callback onAuthRequired
. In fact we could use that same callback.
@@ -194,6 +194,10 @@ For PKCE flow, this should be left undefined or set to `['code']`. | |||
1. `auth.login` is called | |||
2. SecureRoute is accessed without authentication | |||
|
|||
- **onTokenError** *(optional)* - callback function. If there is an error while renewing a token, the error will be passed to a handler function. The default handler calls `login()` to initiate a login flow. Passing a function here will override the default handler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same message re: name vs docs
@bretterer updated based on feedback |
e6943c1
to
01dac25
Compare
Closed in favor of #648 |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: 245536
What is the new behavior?
Exposes the internal
TokenManager
instance via a convenience method for users of the Vue, Angular or React libraries. This allows (among other possibilities), adding event listeners for token expired or login_required events.Does this PR introduce a breaking change?
Other information
No new behavior is being added to TokenManager. Additional tests and minor documentation additions related to this task are in PR: okta/okta-auth-js#247
Reviewers