View Source ExNylas.HostedAuthentication (ExNylas v0.9.0)

Nylas hosted authentication

Nylas docs

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)
@spec build!(map() | struct()) :: struct()

Create and validate a hosted authentication, use create/update to send to Nylas.

Examples

iex> result = ExNylas.HostedAuthentication.build!(payload)
Link to this function

exchange_code_for_token(conn, code, redirect_uri, grant_type \\ "authorization_code")

View Source

Exchange an authorization code for a Nylas access token

Examples

iex> {:ok, access_token} = ExNylas.HostedAuthentication.exchange_code_for_token(conn, code, redirect)
Link to this function

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)
Link to this function

get_auth_url(conn, options)

View Source
@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:

  1. client_id is required (on the connection struct)
  2. 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)
Link to this function

get_auth_url!(conn, options)

View Source
@spec get_auth_url!(ExNylas.Connection.t(), map() | Keyword.t()) :: String.t()

Returns the URI to send the end user

Notes:

  1. client_id is required (on the connection struct)
  2. 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)