ExForce v0.2.2 ExForce.OAuth View Source

Handles OAuth2

Grant Types

Link to this section Summary

Functions

Returns the authorize url based on the configuration

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

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(url, opts \\ [headers: [{"user-agent", "ex_force"}]]) View Source

Returns client for OAuth functions

Options

  • :user_agent
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"
)

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"
)