ExForce v0.4.0 ExForce.OAuth View Source

Handles OAuth2

Grant Types

Link to this section Summary

Link to this section Types

Link to this section Functions

Link to this function

authorize_url(endpoint, enum)

View Source
authorize_url(String.t(), Enum.t()) :: String.t()

Returns the authorize url based on the configuration.

authorization_code

ExForce.OAuth.authorize_url(
  "https://login.salesforce.com",
  response_type: "code",
  client_id: "client-id",
  redirect_uri: "https://example.com/callback"
)

token

ExForce.OAuth.authorize_url(
  "https://login.salesforce.com",
  response_type: "token",
  client_id: "client-id",
  redirect_uri: "https://example.com/callback"
)
Link to this function

build_client(instance_url)

View Source

See ExForce.Client.build_oauth_client/1.

Link to this function

build_client(instance_url, opts)

View Source

See ExForce.Client.build_oauth_client/2.

Link to this function

get_token(url, payload)

View Source
get_token(ExForce.Client.t() | String.t(), list()) ::
  {:ok, ExForce.OAuthResponse.t()} | {:error, :invalid_signature | term()}

Fetches an ExForce.OAuthResponse struct by making a request to the token endpoint.

authorization_code

ExForce.OAuth.get_token(
  "https://login.salesforce.com",
  grant_type: "authorization_code",
  code: "code",
  redirect_uri: "https://example.com/callback",
  client_id: "client_id",
  client_secret: "client_secret"
)

password

ExForce.OAuth.get_token(
  "https://login.salesforce.com",
  grant_type: "password",
  client_id: "client_id",
  client_secret: "client_secret",
  username: "username",
  password: "password" <> "security_token"
)

refresh_token

ExForce.OAuth.get_token(
  "https://login.salesforce.com",
  grant_type: "refresh_token",
  client_id: "client_id",
  client_secret: "client_secret",
  refresh_token: "refresh_token"
)