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
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 section Functions
Link to this function
authorize_url(client, scope \\ "https://www.googleapis.com/auth/youtube")
View Source
Returns the authorization url with authorization informaation.
The authorization URL includes the following query parameters
access_type
- is set tooffline
which allows to refresh the access token laterclient_id
- Theclient_id
value as given on Google’s Credentials pageinclude_granted_scopes
- set totrue
to enable incremental authorization. See the Incremental Authorization section.redirect_uri
- The OAuth callback URL that Google calls after successful authorizationresponse_type
- value iscode
to return an authorization codestate
- set tostate_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"
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"}}