Conversation
1bfb6e0 to
d62d5ab
Compare
seratch
approved these changes
Jul 15, 2021
Contributor
seratch
left a comment
There was a problem hiding this comment.
Apart from the type definition re-generation and using the new one for oauth.v2.exchange API method, this pull request should be ready for merging
packages/web-api/src/methods.ts
Outdated
| access: bindApiCall<OAuthAccessArguments, OauthAccessResponse>(this, 'oauth.access'), | ||
| v2: { | ||
| access: bindApiCall<OAuthV2AccessArguments, OauthV2AccessResponse>(this, 'oauth.v2.access'), | ||
| exchange: bindApiCall<OAuthV2ExchangeArguments, OauthV2AccessResponse>(this, 'oauth.v2.exchange'), |
Contributor
There was a problem hiding this comment.
@misscoded Can you run ./scripts/generate-web-api-types.sh? The command generates the response type for this endpoint. Also, it adds a few missing fields in other types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1241
HOW IT WORKS
On OAuth installation (the only installation flow allowed when token rotation is enabled), new access tokens are stored as they have been, but now include an accompanying
refresh_tokenandexpires_in. Therefresh_token(does not expire) is used to "trade-in" for a newaccess_tokenandrefresh_tokenpair.For each token (
bot|user), we use theexpires_invalue to calculate and store a corresponding future expiry timestamp (UTC, seconds).Each time an event is received,
authorizegets run. Here we determine if token rotation is enabled. If so, we check the expiry of the token(s) and refresh those that have expired or will expire within 2 hours. We then update the returnedauthResultand theInstallation.NOTABLE CHANGES
AuthorizationResulthas four new keys:botRefreshToken,botTokenExpiresAt,userRefreshToken, anduserTokenExpiresAt. This was to handle apps that have both User and Bot tokens while still keeping the shape flat.Installationhas four new keys: arefreshTokenandexpiresAtfor both theuserandbotobjects.Requirements (place an
xin each[ ])