Exyt v0.2.0 Exyt.Client View Source

This module defines a basic client to communicate with the Youtube API.

Link to this section Summary

Functions

Returns the authorization url with authorization informaation

Builds a Client struct

Returns the token url to request an access token. This token is used to access the different API functions

Link to this section Types

Link to this type authorize_url() View Source
authorize_url() :: binary()
Link to this type client_id() View Source
client_id() :: binary()
Link to this type client_secret() View Source
client_secret() :: binary()
Link to this type redirect_uri() View Source
redirect_uri() :: binary()
Link to this type t() View Source
t() :: %Exyt.Client{api_url: api_url(), authorize_url: authorize_url(), client_id: client_id(), client_secret: term(), redirect_uri: redirect_uri(), site: site(), token: token(), token_url: token_url()}
Link to this type token_url() View Source
token_url() :: binary()

Link to this section Functions

Link to this function authorize_url(client, scope \\ "https://www.googleapis.com/auth/youtube") View Source
authorize_url(t(), binary()) :: binary()

Returns the authorization url with authorization informaation.

The authorization URL includes the following query parameters

  • access_type - is set to offline which allows to refresh the access token later
  • client_id - The client_id value as given on Google’s Credentials page
  • include_granted_scopes - set to true to enable incremental authorization. See the Incremental Authorization section.
  • redirect_uri - The OAuth callback URL that Google calls after successful authorization
  • response_type - value is code to return an authorization code
  • state - set to state_parameter_passthrough_value to allow this Client to send application specific key, value pairs back.

Example

iex> Exyt.Client.authorize_url()
"https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=&" <>
"include_granted_scopes=true&redirect_uri=&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube" <>
"&state=state_parameter_passthrough_value"
Link to this function new(client \\ %Exyt.Client{}, opts) View Source
new(t(), Keyword.t()) :: t()

Builds a Client struct.

Without configured settings, the following parameters are required to authorize against Google OAuth, client_id, client_secret and redirect_uri.

When an access token is already available the %Exyt.Client struct can be initialized with the token parameter.

Client struct fields

Without configured settings, the following parameters are required for authorization

  • client_id - The client id of the credentials.
  • client_secret - The client secret of the credentials..
  • redirect_uri - The OAuth2 callback URL that contains authorization code.
  • authorize_url - The absolute or relative URL path to the authorization endpoint.
  • token_url - The absolute or relative URL to the access token endpoint.
  • site - The site URL to authenticate with.
  • token - Either a string containing the access token or a%Exyt.AccessToken{} struct received after successful authorization.
  • api_url - The absolute URL to Youtube API v3.

Examples

iex> Exyt.Client.new(client_id: "1234…", client_secret: "abcd…", redirect_uri: "http://example.com/callback")
%Exyt.Client{client_id: "1234…", client_secret: "abcd…", redirect_uri: "http://example.com/callback"}

iex> Exyt.Client.new(token: "123456")
%Exyt.Client{token: %Exyt.AccessToken{access_token: "123456"}}
Link to this function token_url(client) View Source
token_url(t()) :: binary()

Returns the token url to request an access token. This token is used to access the different API functions.

Example

iex> Exyt.Client.token_url()
"https://accounts.google.com/o/oauth2/token"