Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OAuthResource

Hierarchy

Index

Constructors

constructor

Properties

Protected basePath

basePath: string

Protected httpService

httpService: HTTPService

Protected resourcePath

resourcePath: string

Private userAgent

userAgent: string

Methods

generateOAuthURL

  • generateOAuthURL(oauthClientId: string): string
  • Generates the OAuthURL where your users need to sign up to give your application access to authorized endpoints.

    let url = traveler.oauth.generateOAuthURL('clientId');
    memberof

    Traveler

    Parameters

    • oauthClientId: string

    Returns string

getAccessToken

  • getAccessToken(code: string, oauthClientId?: string, oauthClientSecret?: string): Promise<OAuthResponse>
  • Retreive the Oauth access token from the authorization code

    traveler.oauth
     .getAccessToken('code', 'oauthClientId', 'oauthClientSecret')
     .then(response => {
       console.log(response);
     })
     .catch(err => {
       console.log(err);
     });
    memberof

    Traveler

    Parameters

    • code: string

      The authorization code from the oauth redirect url

    • Optional oauthClientId: string
    • Optional oauthClientSecret: string

    Returns Promise<OAuthResponse>

refreshToken

  • refreshToken(refreshToken: string, oauthClientId: string, oauthClientSecret: string): Promise<OAuthResponse>
  • Use the refreshToken to retrieve a new valid access_token. Please keep the expiration durations in mind. This is only possible with a confidential app, as only this will get a refresh token to use

    traveler.oauth
     .refreshToken('refreshToken', 'oauthClientId', 'oauthClientSecret')
     .then(response => {
       console.log(response);
     })
     .catch(err => {
       console.log(err);
     });
    memberof

    Traveler

    Parameters

    • refreshToken: string
    • oauthClientId: string

      The oauth client id

    • oauthClientSecret: string

      The oauth client secret key

    Returns Promise<OAuthResponse>