View Source ExNylas.HostedAuthentication (ExNylas v0.9.0)
Nylas hosted authentication
Summary
Functions
Create and validate a hosted authentication, use create/update to send to Nylas.
Create and validate a hosted authentication, use create/update to send to Nylas.
Exchange an authorization code for a Nylas access token
Exchange an authorization code for a Nylas access token
Returns the URI to send the end user
Returns the URI to send the end user
Functions
@spec build(map() | struct()) :: {:ok, struct()} | {:error, Ecto.Changeset.t()}
Create and validate a hosted authentication, use create/update to send to Nylas.
Examples
iex> {:ok, result} = ExNylas.HostedAuthentication.build(payload)
Create and validate a hosted authentication, use create/update to send to Nylas.
Examples
iex> result = ExNylas.HostedAuthentication.build!(payload)
exchange_code_for_token(conn, code, redirect_uri, grant_type \\ "authorization_code")
View Source@spec exchange_code_for_token( ExNylas.Connection.t(), String.t(), String.t(), String.t() ) :: {:ok, ExNylas.HostedAuthentication.Grant.t()} | {:error, ExNylas.HostedAuthentication.Error.t()}
Exchange an authorization code for a Nylas access token
Examples
iex> {:ok, access_token} = ExNylas.HostedAuthentication.exchange_code_for_token(conn, code, redirect)
exchange_code_for_token!(conn, code, redirect_uri, grant_type \\ "authorization_code")
View Source@spec exchange_code_for_token!( ExNylas.Connection.t(), String.t(), String.t(), String.t() ) :: ExNylas.HostedAuthentication.Grant.t()
Exchange an authorization code for a Nylas access token
Examples
iex> access_token = ExNylas.HostedAuthentication.exchange_code_for_token!(conn, code, redirect)
@spec get_auth_url(ExNylas.Connection.t(), map() | Keyword.t()) :: {:ok, String.t()} | {:error, String.t()}
Returns the URI to send the end user
Notes:
client_id
is required (on the connection struct)redirect_uri
is required (in options) and must be registered on the Nylas application
Optionally use ExNylas.HostedAuthentication.build/1 to validate options.
Examples
iex> options = %{login_hint: "hello@nylas.com", redirect_uri: "https://mycoolapp.com/auth", state: "random_string", scope: ["provider_scope_1", "provider_scope_2"]}
iex> {:ok, uri} = ExNylas.HostedAuthentication.get_auth_url(conn, options)
@spec get_auth_url!(ExNylas.Connection.t(), map() | Keyword.t()) :: String.t()
Returns the URI to send the end user
Notes:
client_id
is required (on the connection struct)redirect_uri
is required (in options) and must be registered on the Nylas application
Optionally use ExNylas.HostedAuthentication.build/1 to validate options.
Examples
iex> options = %{login_hint: "hello@nylas.com", redirect_uri: "https://mycoolapp.com/auth", state: "random_string", scope: ["provider_scope_1", "provider_scope_2"]}
iex> uri = ExNylas.HostedAuthentication.get_auth_url!(conn, options)