MPX v0.1.8 Mpx.Authentication.Body

Defines types and functions for dealing with authentication body and parameters.

Summary

Types

t()

What is included in a post request when authenticating

Functions

Build a x-www-form-urlencoded query string to send in the authentication request to MP

Types

t ::
  [username: String.t, password: String.t, client_id: String.t, client_secret: String.t] |
  [client_id: String.t, client_secret: String.t]

What is included in a post request when authenticating

Functions

get_auth_body(opts)

Specs

get_auth_body(t | nil) :: String.t

Build a x-www-form-urlencoded query string to send in the authentication request to MP

If called with an empty list, it will look in the configuration for:

config :mpx,
  mp_username: "user",
  mp_password: "password",
  mp_client_id: "client",
  mp_client_secret: "shhh"

If called with just the client_id and client_secret, we assume that you are trying tos authorize a client, so the grant_type is specified as client_credentials

Examples

iex>Mpx.Authentication.Body.get_auth_body(username: “user”, password: “pass”, client_id: “client”, client_secret: “secret”) “username=user&password=pass&client_id=client&client_secret=secret&grant_type=password”

iex>Mpx.Authentication.Body.get_auth_body([]) #pulls data from the configuration “username=user&password=password&client_id=client&client_secret=shhh&grant_type=password”

iex>Mpx.Authentication.Body.get_auth_body(client_id: “client”, client_secret: “password”) “client_id=client&client_secret=password&grant_type=client_credentials”