Emitted when the authenticated state changes. AuthorizationManager.events#authenticated
Emitted when the user revokes their authentication. AuthorizationManager.events#revoke
The storage system used by the AuthorizationManager.
The AuthorizationManager is considered authenticated if it has a valid Globus Auth token.
It does not necessarily mean that it has a valid token for a specific resource server.
Set the authenticated state and emit the authenticated event.
The user information decoded from the id_token (JWT) of the current Globus Auth token.
This method can be used instead of auth.oauth2.userinfo to get the user information without an additional request.
IMPORTANT: The id_token can only be processed if the openid scope is requested during the authorization process.
Additionally, the profile and email scopes are required to get the full user information.
Add a Globus Auth token response to storage, if other_tokens are present they are also added.
This method is mostly used internally by the AuthorizationManager, but can be used by downstream
consumers to add tokens to storage if necessary.
Complete an authorization code flow started with startAuthorization(): validate the state,
exchange the code for tokens, and add them to the instance (without resetting existing tokens).
The value returned by startAuthorization().
The code (and state) received on the redirect. A URL or URLSearchParams of the redirect
can be provided directly, in which case it must include the expected state. When a { code } object is
provided, state is validated if present, and can be omitted when the user copies the code from the Globus
Auth "auth code" page.
Optionaloptions: { includeConsentedScopes?: boolean }
OptionalincludeConsentedScopes?: booleanReturn tokens for all scopes the user has consented to for the client.
Retrieve the Globus Auth token managed by the instance.
Get a token for a resource server that is valid for at least minValidityMs, refreshing it if necessary (and possible).
minValidityMs, it is returned as-is.refresh_token, it is refreshed (see refreshToken – one refresh at a time per resource server)
and the new token is returned.refresh_token, or the refresh fails), the stored token is returned if it
is not yet expired, otherwise null.4.3.0) are returned as-is.An expired token is never returned.
The resource server of the token, e.g., transfer.api.globus.org.
Optionaloptions: { minValidityMs?: number; throwOnError?: boolean }
OptionalminValidityMs?: numberThe minimum number of milliseconds the token should be valid for.
OptionalthrowOnError?: booleanWhen true, a failed refresh throws an OAuthTokenError instead of falling back
to the stored token or null. null is still returned when there is no stored token.
Process a well-formed Authorization Requirements error response from a Globus service and redirect the user to the Globus Auth login page with the necessary parameters.
Optionaloptions: { additionalParams?: { [key: string]: string } }This method will attempt to complete the PKCE protocol flow.
Process a well-formed ConsentRequired error response from a Globus service
and redirect the user to the Globus Auth login page with the necessary parameters.
Optionaloptions: { additionalParams?: { [key: string]: string } }Handle an error response from a Globus service in the context of this AuthorizationManager.
This method will introspect the response and attempt to handle any errors that should result
in some additional Globus Auth interaction.
The error response from a Globus service.
Optionaloptions: true | { additionalParams?: { [key: string]: string }; execute?: true }
Options for handling the error response. If a boolean is provided, this will be treated as the options.execute value.
OptionaladditionalParams?: { [key: string]: string }Additional query parameters to be included with the transport generated URL.
Optionalexecute?: trueWhether to execute the handler immediately.
Handle an error response from a Globus service in the context of this AuthorizationManager.
This method will introspect the response and attempt to handle any errors that should result
in some additional Globus Auth interaction.
The error response from a Globus service.
Optionaloptions: false | { additionalParams?: { [key: string]: string }; execute?: false }
Options for handling the error response. If a boolean is provided, this will be treated as the options.execute value.
OptionaladditionalParams?: { [key: string]: string }Additional query parameters to be included with the transport generated URL.
Optionalexecute?: falseWhether to execute the handler immediately.
Whether or not the instance has a reference to a Globus Auth token.
Initiate the login process by redirecting to the Globus Auth login page.
IMPORTANT: This method will reset the instance state before initiating the login process,
including clearing all tokens from storage. If you need to maintain the current state,
use the AuthorizationManager.prompt() method.
Use the refresh_token attribute of a token to obtain a new access token.
Only one refresh request is made at a time for a resource server; concurrent calls for the same resource server will receive the result of the in-flight request.
If the response omits a refresh_token, the existing refresh token is preserved.
The well-formed token with a refresh_token attribute.
When true, an OAuthTokenError is thrown when the token cannot be refreshed,
instead of resolving null. Use this to distinguish a refused refresh (error.requiresReauthentication)
from an outage (error.status >= 500) or a network error (error.status === undefined).
The token response, or null if the token could not be refreshed (unless throwOnError is set).
Use the refresh_token attribute of a token to obtain a new access token.
Only one refresh request is made at a time for a resource server; concurrent calls for the same resource server will receive the result of the in-flight request.
If the response omits a refresh_token, the existing refresh token is preserved.
The well-formed token with a refresh_token attribute.
Optionaloptions: { throwOnError?: boolean }
OptionalthrowOnError?: booleanWhen true, an OAuthTokenError is thrown when the token cannot be refreshed,
instead of resolving null. Use this to distinguish a refused refresh (error.requiresReauthentication)
from an outage (error.status >= 500) or a network error (error.status === undefined).
The token response, or null if the token could not be refreshed (unless throwOnError is set).
Attempt to refresh all of the tokens managed by the instance.
This method will only attempt to refresh tokens that have a refresh_token attribute.
Reset the authenticated state and clear all tokens from storage.
This method does not emit the revoke event. If you need to emit the revoke event, use the AuthorizationManager.revoke method.
Revoke all of the available tokens (access tokens and refresh tokens), call AuthorizationManager.reset,
and emit the revoke event.
The instance is always reset (all tokens are removed from storage), and the revoke event is always
emitted, even when one or more revocation requests fail. Failed revocations are reported in the
resolved value (and the revoke event payload) so they can be logged or retried.
Start an authorization code flow (with PKCE) without using a browser transport, e.g., in a CLI, a local MCP server, or a desktop application.
This method only builds the authorization request; it does not navigate, open a browser, or modify the instance state.
Direct the user to the returned url, then pass the returned request, along with the code (and state) received
on the redirect, to completeAuthorization().
Unlike login(), the instance is not reset; tokens obtained with completeAuthorization() are added
to the existing tokens, so this can be used to request additional consents.
Optionaloptions: StartAuthorizationOptionsconst request = await manager.startAuthorization();
console.log(`Please log in: ${request.url}`);
const code = await readCodeFromStdin();
await manager.completeAuthorization(request, { code });
const request = await manager.startAuthorization({ redirect: 'http://127.0.0.1:8080/callback' });
openBrowser(request.url);
// ...in the HTTP handler for `/callback`:
await manager.completeAuthorization(request, new URL(req.url, 'http://127.0.0.1:8080'));
Provides management of Globus authorization context for your application.
ConsentRequired,authorization_requirements)Once you configure your instance, you can determine the authenticated state using
manager.authenticated.To prompt a user to authenticate, call
manager.login()on user interaction – this will initiate the OAuth protocol flow with your configured client and scopes, resulting in an initial redirect to Globus Auth.Once the user authenticates with Globus Auth, they will be redirected to your application using the configured
redirectURL. On this URL, you will need to callmanager.handleCodeRedirect(using a manager instance configured in the same manner that initiated themanager.login()call) to complete the PKCE flow, exchanging the provided code for a valid token, or tokens.All tokens managed by the
AuthorizationManagerinstance can be found onmanager.token.Registering your Globus Application
The
AuthorizationManagerexpects your Globus Application to be registered as an OAuth public client. In this Globus Web Application, this option is referenced as "Register a thick client or script that will be installed and run by users on their devices".Example: Creating an AuthorizationManager instance.
Usage with Service Methods
Once you have an instance of an
AuthorizationManager, it can be passed to any service method asServiceMethodOptions.managerorSDKOptions.manageroption. The service method will determine if a token is required to make the request and will use theAuthorizationManagerto retrieve the token.Example: Using the AuthorizationManager with a service method.