Class SpellscrollOAuthClient
Only the refresh token is persisted (via SpellscrollTokenStore, which delegates to
the OS native credential store). Access tokens are obtained fresh each Gradle run by
exchanging the refresh token, so they never touch disk.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a fresh access token by silently exchanging the stored refresh token.login()Runs the interactive browser-based OAuth2 flow, presenting a provider selection page.login(SpellscrollOAuthClient.Provider provider) Runs the interactive browser-based OAuth2 flow forprovider.
-
Constructor Details
-
SpellscrollOAuthClient
-
-
Method Details
-
getValidToken
Returns a fresh access token by silently exchanging the stored refresh token.Because we don't record which provider issued the stored token, we try Google first then Microsoft — only the correct provider will accept the token. Returns
nullif no refresh token is stored or both providers reject it, in which case the caller should invokelogin().- Throws:
IOExceptionInterruptedException
-
login
Runs the interactive browser-based OAuth2 flow, presenting a provider selection page.Opens a local HTTP server and directs the browser to a sign-in page where the user can choose between Google and Microsoft. Once a provider is chosen the standard Authorization Code + PKCE flow completes in the same browser tab. Blocks until the provider redirects back (up to 5 minutes). The resulting refresh token is persisted to the OS credential store.
- Returns:
- the access token for the current session
- Throws:
IOException- if network I/O failsInterruptedException- if the waiting thread is interrupted
-
login
public String login(SpellscrollOAuthClient.Provider provider) throws IOException, InterruptedException Runs the interactive browser-based OAuth2 flow forprovider.The localhost redirect server is started before the browser is opened to ensure the authorization code is never missed. Blocks until the provider redirects back (up to 5 minutes). The resulting refresh token is persisted to the OS credential store.
- Returns:
- the access token for the current session
- Throws:
IOException- if network I/O failsInterruptedException- if the waiting thread is interrupted
-