Gamora.API (gamora v0.15.0)

View Source

This module wraps the functions to access IDP's endpoints.

Summary

Functions

Gets token's data based on an access token using introspection endpoint in the IDP.

Gets user's data based on an access token using userinfo endpoint in the IDP.

Functions

introspect(access_token)

@spec introspect(access_token :: String.t()) ::
  {:ok, OAuth2.Response.t()} | {:error, term()}

Gets token's data based on an access token using introspection endpoint in the IDP.

Parameters

  • access_token: String [Access token generated by the IDP].

Examples

iex> introspect("bGWcAKadGrBwM...")
{:ok, %{active: true, ...}

iex> introspect("InvalidAccessToken")
{:error, :access_token_invalid}

userinfo(access_token)

@spec userinfo(access_token :: String.t()) ::
  {:ok, OAuth2.Response.t()} | {:error, term()}

Gets user's data based on an access token using userinfo endpoint in the IDP.

Parameters

  • access_token: String [Access token generated by the IDP].

Examples

iex> userinfo("bGWcAKadGrBwM...")
{:ok, %{email: "test@example", phone_number: "+523344556677"}}

iex> userinfo("InvalidAccessToken")
{:error, :access_token_invalid}