View Source Gamora.API (gamora v0.13.0)

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

Link to this section 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.

Link to this section Functions

Link to this function

introspect(access_token)

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

Parameters

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

examples

Examples

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

iex> introspect("InvalidAccessToken")
{:error, :access_token_invalid}
@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

Parameters

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

examples

Examples

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

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