Options
All
  • Public
  • Public/Protected
  • All
Menu
description

The dApp's Strava OAuth driver. This class is used to determine communication, transport and process to connect and integrate to the Strava provider.

since

v0.3.0

Hierarchy

Index

Constructors

Properties

codeFieldName: string = "code"

The driver's codeFieldName. This field indicates the name of the code field in this driver. Its value should always be 'code'.

access

protected

var

{string}

dataFieldName: string = "state"

The driver's dataFieldName. This field indicates the name of the data field in this driver. Its value should always be 'state'.

access

protected

var

{string}

httpService: HttpRequestHandler

The driver's HTTP service. It's a handler for HTTP requests and contains methods for executing remote API calls, e.g. calling a GET HTTP API endpoint.

access

protected

var

{HttpRequestHandler}

name: string
usesSecondsUTC: boolean = true

The driver's value to determine whether seconds are used to express UTC timestamps (if set to false, milliseconds are used). This field indicates the type of timestamp returned with this driver.

This Strava OAuth implementation uses seconds since epoch when it expresses/returns UTC timestamps that represent an access token's expiration time.

see

https://developers.strava.com/docs/authentication/#response-parameters

access

protected

var

{boolean}

Accessors

  • get codeField(): string
  • get dataField(): string
  • get providerName(): string
  • get usesUTCSecondsToEpoch(): boolean
  • Getter that determines whether this driver uses seconds (rather than milliseconds) to express a timestamp in UTC format.

    access

    public

    Returns boolean

    Whether this driver uses seconds to express UTC timestamps.

Methods

  • buildAuthorizeQuery(data: string): string
  • Method to return the authorize query to this driver's provider. This is the query parameters that will be included after the authorized url.

    Note that in addition to the query parameters included in the super class BasicOAuthDriver, this method also adds two new parameters response_type=code and approval_prompt=auto.

    access

    protected

    Parameters

    • data: string

      The data value to include in this query.

    Returns string

    The full query parameters.

  • executeRequest(accessToken: string, endpointUri: string, method?: HttpMethod, body?: any, options?: any, headers?: any): Promise<ResponseStatusDTO>
  • Method to execute a request calling the driver's provider API.

    access

    public

    async

    Parameters

    • accessToken: string

      The access token attached as a Bearer token to the request.

    • endpointUri: string

      The endpoint URI of the driver's provider API.

    • method: HttpMethod = "GET"

      (Optional) The HTTP method used for the request, e.g. "GET". Defaults to "GET".

    • body: any = {}

      (Optional) The body of the request, as used with "POST" or "PUT" requests. Defaults to an empty object.

    • options: any = {}

      (Optional) An options object that is directly passed to axios before request execution. Defaults to an empty object.

    • headers: any = {}

    Returns Promise<ResponseStatusDTO>

    A promise containing the response and status in ResponseStatusDTO.

  • Method to return the remote access token. The result is an access/refresh token pair. This method requires the use of an authorization code that is provided by the provider.

    These access tokens are always signed with the dApp's auth secret and expire after 1 hour (one hour).

    access

    public

    async

    Parameters

    • code: string

      The required code field value.

    • Optional data: string

      The required data field value.

    Returns Promise<AccessTokenDTO>

    A promise containing the result AccessTokenDTO.

  • getAuthorizeURL(extra: string): string
  • Method to transform an entity as described by the data provider API. Typically, this method is used to handle the transformation of remote objects (from data provider API) to internal objects in the backend runtime's database.

    e.g. This method is used to transform activity data as defined by the Strava API, into ActivityData as defined internally.

    This implementation is currently compatible with remote activity data as defined in the Strava API. It uses the Activity class to transform the activity data.

    access

    public

    Parameters

    Returns OAuthEntity

    A parsed entity object.

  • requestAccessToken(params: Record<string, string>): Promise<AccessTokenDTO>
  • Helper method that executes the actual access token request using a set of params parameters. The parameters set must contain the following fields:

    • client_id: Your Strava App's client identifier.
    • client_secret: Your Strava App's client secret.
    • grant_type: One of authorization_code or refresh_token.

      When executing a authorization request for the access token, the field authorization_code and code are obligatory as well. When executing a refresh request for the access token, it is the field refresh_token that is obligatory (no code).
    access

    protected

    async

    Parameters

    • params: Record<string, string>

      The parameters for the access token request.

    Returns Promise<AccessTokenDTO>

    A promise containing the resulting AccessTokenDTO object.

Generated using TypeDoc