Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OAuth

Hierarchy

  • OAuth

Index

Constructors

constructor

  • new OAuth(grantType: GrantType | string, clientId: string, clientSecret?: string, redirectURI?: string, oAuthURL?: string): OAuth
  • Parameters

    • grantType: GrantType | string
    • clientId: string
    • Optional clientSecret: string
    • Optional redirectURI: string
    • Default value oAuthURL: string = "https://cloud.cocoon.io/oauth/"

    Returns OAuth

Accessors

accessTokenURL

  • get accessTokenURL(): string
  • Returns string

authorizationURL

  • get authorizationURL(): string
  • Returns string

logoutURL

  • get logoutURL(): string
  • Returns string

Methods

authorizeAuthorizationCode

  • authorizeAuthorizationCode(scope?: string): string
  • Generate the URL where the user can authorize the application following the Authorization Code OAuth flow.

    Parameters

    • Optional scope: string

      Scope of the access the application requests.

    Returns string

    The URL where the user can authorize the application.

authorizeImplicit

  • authorizeImplicit(scope?: string): string
  • Generate the URL where the user can authorize the application following the Implicit OAuth flow.

    Parameters

    • Optional scope: string

      Scope of the access the application requests.

    Returns string

    The URL where the user can authorize the application.

logout

  • logout(): Promise<void>
  • Log out of the API.

    Returns Promise<void>

    Promise of a successful logout.

tokenExchangeAuthorizationCode

  • tokenExchangeAuthorizationCode(pCode: string, state: string): Promise<IAccessToken>
  • Exchange the code you got after the user authorized the application for the access token following the Authorization Code OAuth flow.

    Parameters

    • pCode: string

      Code found in the redirect URL, as a parameter, after the user authorizes the application.

    • state: string

      Random string present in the redirect URL, as a parameter, after the user authorizes the application. This object created it when generating the authorization URL. The server should have returned the same string and will be tested now.

    Returns Promise<IAccessToken>

    Promise of the access token.

tokenExchangeClientCredentials

  • tokenExchangeClientCredentials(): void
  • Returns void

tokenExchangePassword

  • tokenExchangePassword(pUsername: string, pPassword: string): Promise<IAccessToken>
  • Exchange a username and password for the access token following the Password OAuth flow.

    Parameters

    • pUsername: string

      Username of a user.

    • pPassword: string

      Password of a user.

    Returns Promise<IAccessToken>

    Promise of the access token.

Generated using TypeDoc