-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Integration manager refactoring & Integration tokens auto refreshing #2949
Open
Samuel38
wants to merge
13
commits into
crowbartools:v5
Choose a base branch
from
Samuel38:IntegrationManager-refactoring
base: v5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Integration manager refactoring & Integration tokens auto refreshing #2949
Samuel38
wants to merge
13
commits into
crowbartools:v5
from
Samuel38:IntegrationManager-refactoring
+479
−171
Conversation
This file contains 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
Fixing a bug in the createToken method of oauth2-client that made it so token was always seen as non expired by having our own createToken method. Adding the ability to pass options to the oauth2 client to be added with the requests. This allows for Integrations to work with APIs that require certain additional fields (For example Id and Secret in body as required by Tiltify) Adding a refreshToken() method to IntegrationManager to allow integrations to manually request a refresh token id autoRefresh is disabled. Adding a getAuth() method to IntegrationManager. Integrations should use this method to get the auth with a valid token to allow the IntegrationManager to autoRefresh the token. Emitting a "token-refreshed" event when the token is refreshed by either method in case the integration needs to do something with it. Renaming the oauth property to auth so it is consistent, since both appeared, and consistent with the type definition currently exposed to integrations.
- TS for IntegrationManager - `IntegrationData` now must contain property `linked` - `refreshToken()` now returns `AuthData` instead of `IntegrationData` - TS for AuthAPIController - Changed `AuthManager` to rely as little as possilbe on `ClientOAuth2` types and more on our own `AuthDetails` type which is better type defined. - Changed `obtainmentTimestamp` custom `AuthDetails` property which was used by twitch auth to `created_at`, more consistent with the `expires_in` standard one. - Added `client_id` and `client_secret` by default in the request body to all OAuth requests instead of just initial token request. - Fixed a few typing and linting mistakes in extralife integration. - created integrations type file, which exposes IntegrationManager and a generic abstract class for IntegrationController which integrations can inherit to emit their custom events and ensure interfacing with the integrationManager.
- JSonDb properly restores numbers, not Dates, so a timestamp is better stored - Solving a bug where token created_at and expires_at wouldn't properly refresh when refreshing tokens, leading to chain refreshing.
…grations don't break.
Created related PR in firebot-custom-scripts-types with changes that reflect these. |
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.
Description of the Change
client_id
andclient_secret
by default to all requests for OAuth2 code flowAuthData
type for all methods that interact with other modules than AuthManagerAuthData
type so we include timestamps for creation and expiry (expires_at
is now a timestamp so its type is naturally restored by JSonDb)refreshTokenIfExpired()
so it doesn't always think the token is still validobtainmentTimestamp
tocreated_at
to be consistent with norm and some providersoauth
toauth
in IntegrationData so we're consistant across the IntegrationManagerFirebotSettings
andintegrationDefinition
extension types.refreshToken()
method toIntegrationManager
to manually ask to refresh a token if autoRefresh isn't enabled.getAuth()
method that attempts to returns a validLinkData
object (auth token or Account ID), auto refreshing the token if enabled and necessary. This should be the preferred method of getting access token.token-refreshed
event emitted by IntegrationManager each one an integration's token is refreshed.integrationCanConnect()
andintegrationIsLinked()
methods that were pulling from the wrong object.Applicable Issues
auth
vsoauth
properties confusing to get auth data.Testing
getAuth()
works with autoRefresh for token.token-refreshed
is emitted and can be received by integrationNot tested :