gandalf v0.2.0 Gandalf.GrantType.ClientCredentials

ClientCredentials grant type for OAuth2 Authorization Server

Summary

Functions

Authorize client for ‘client owner’ using client credentials

Functions

authorize(arg1)

Authorize client for ‘client owner’ using client credentials.

For authorization, authorize function requires a map contains ‘client_id’ and ‘client_secret’. With valid credentials; it automatically creates access_token and refresh_token(if enabled via config) then it returns Gandalf.Model.Token struct, otherwise {:error, Map, :http_status_code}.

Examples

# With OAuth2 optional scope
Gandalf.GrantType.ClientCredentials.authorize(%{
  "client_id" => "52024ca6-cf1d-4a9d-bfb6-9bc5023ad56e",
  "client_secret" => "Wi7Y_Q5LU4iIwJArgqXq2Q",
  "scope" => "read"
%})

# Without OAuth2 optional scope
Gandalf.GrantType.ClientCredentials.authorize(%{
  "client_id" => "52024ca6-cf1d-4a9d-bfb6-9bc5023ad56e",
  "client_secret" => "Wi7Y_Q5LU4iIwJArgqXq2Q"
%})