matrix-js-sdk
    Preparing search index...

    Class OAuth2

    Index
    context: Required<Context>
    • Attempt to exchange authorization code for bearer token.

      Takes the authorization code returned by the OAuth2 Provider via the authorization URL, and makes a request to the Token Endpoint, to obtain the access token, refresh token, etc.

      Parameters

      • code: string

        authorization code as returned by IdP during authorization

      Returns Promise<BearerTokenResponse>

      a validated bearer token response

      An Error with message set to an entry in OAuth2Error, when the request fails, or the returned token response is invalid.

    • Generate a URL to attempt authorization with the OP See https://spec.matrix.org/v1.18/client-server-api/#authorization-code-flow

      Parameters

      • state: string

        A unique opaque identifier, like a transaction ID, that will allow the client to maintain state between the authorization request and the callback. The app should use this to key the storage for where the rest of the auth context is saved.

      • responseMode: "query" | "fragment" = "fragment"

        The manner in which the IdP should send the secrets back to the app. Defaults to fragment for privacy.

      • Optionalprompt: string

        Optional prompt parameter to pass to the IdP to signal intent, e.g. create for User registration.

      • Optionalscope: string

        The OAuth2 scope to request, will be generated based on the device ID if omitted.

      Returns Promise<string>

      a Promise with the url as a string

    • Revokes the given token

      Parameters

      • token: string

        the token to remove

      • Optionaltype: "access_token" | "refresh_token"

        the type of token, acts as a hint to the IdP

      Returns Promise<void>