View Source ExTrade.Authorization (ExTrade v0.0.1)

Interface to the E*TRADE Authorization API.

More information on the OAuth workflow with E*TRADE can be found in their Developer Guides.

Link to this section Summary

Functions

Retrieves an access token and secret via the Get Access Token endpoint using the provided verifier code, which is then stored in memory and used to construct authorization headers for all API requests.

Constructs an authorization header using the current access tokens stored in memory.

Retrieves a request token and secret via the Get Request Token endpoint, which is then stored in memory and used to construct an authorization URL.

Renews the current access token and secret via the Renew Access Token endpoint.

Revokes the current access token and secret via the Revoke Access Token endpoint.

Link to this section Functions

Link to this function

get_access_token(verifier)

View Source
@spec get_access_token(String.t()) :: :ok | {:error, String.t()}

Retrieves an access token and secret via the Get Access Token endpoint using the provided verifier code, which is then stored in memory and used to construct authorization headers for all API requests.

The access token will become "inactive" after two hours of inactivity. Using renew_access_token/0 will reactivate the inactive access token.

By default, all access tokens are "expired" at the end of the current calendar day, US Eastern time. Once the token has expired, no requests will be processed for that token until the OAuth process is repeated and a new access token is retrieved.

Link to this function

get_authorization_header(method, url)

View Source
@spec get_authorization_header(String.t(), String.t()) :: {String.t(), String.t()}

Constructs an authorization header using the current access tokens stored in memory.

@spec get_authorization_url() :: {:ok | :error, String.t()}

Retrieves a request token and secret via the Get Request Token endpoint, which is then stored in memory and used to construct an authorization URL.

The returned authorization URL can be followed to authenticate with E*TRADE and retrieve the verifier code necessary to invoke get_access_token/1.

The request token, and therefore the generated authorization URL, is only valid for five minutes. After that, a new one will have to be generated.

@spec renew_access_token() :: :ok | {:error, String.t()}

Renews the current access token and secret via the Renew Access Token endpoint.

@spec revoke_access_token() :: :ok | {:error, String.t()}

Revokes the current access token and secret via the Revoke Access Token endpoint.