Pocketeer v0.1.4 Pocketeer.Auth

Authorization module to fetch request_token and access_token from the Pocket API necessary to retrieve, modify or access items.

Summary

Functions

Returns authorization URL for Pocket to authorize the application

Returns authorization URL for Pocket to authorize the application

Requests an access token from the Pocket API

Requests an access token from the Pocket API

Sends a request to fetch a request_token from Pocket

Sends a request to fetch a request_token from Pocket

Functions

authorize_url(map)

Specs

authorize_url(map) :: String.t

Returns authorization URL for Pocket to authorize the application.

Examples

iex> Pocketeer.Auth.authorize_url(%{request_token: "abcd", redirect_uri: "http://example.com"})
"https://getpocket.com/auth/authorize?request_token=abcd&redirect_uri=http%3A%2F%2Fexample.com"

Parameters

  • A struct with request_token and redirect_uri present.
authorize_url(request_token, redirect_uri)

Specs

authorize_url(String.t, String.t) :: String.t

Returns authorization URL for Pocket to authorize the application.

Examples

iex> Pocketeer.Auth.authorize_url("abcd", "http://example.com")
"https://getpocket.com/auth/authorize?request_token=abcd&redirect_uri=http%3A%2F%2Fexample.com"

Parameters

  • request_token: The request token to authorize the app with
  • redirect_uri: The URL the user is redirected to after authorization

Returns the authorization URL with all parameters

get_access_token(map)

Specs

get_access_token(map) ::
  {:ok, map} |
  {:error, HTTPError.t}

Requests an access token from the Pocket API.

The method requires a request_token fetched from Pocketeer.Auth.get_request_token method.

Examples

Pocketeer.Auth.get_access_token(%{consumer_key: "abcd", request_token: "1234"})
{:ok, Response{}}
get_access_token(consumer_key, request_token)

Specs

get_access_token(String.t, String.t) ::
  {:ok, Pocketeer.Response.t} |
  {:error, HTTPError.t}

Requests an access token from the Pocket API.

The method requires a request_token fetched from Pocketeer.Auth.get_request_token method.

Examples

Pocketeer.Auth.get_access_token("abcd", "1234")
{:ok, Response{}}

Parameters

  • consumer_key: The consumer key used from the Pocket API
  • request_token: The request token to authorize the application
get_request_token(map)

Specs

get_request_token(map) ::
  {:ok, Pocketeer.Response.t} |
  {:error, HTTPError.t}

Sends a request to fetch a request_token from Pocket.

Examples

options = %{consumer_key: "1234", redirect_uri: "http://example.com"}
Pocketeer.Auth.get_request_token(options)
get_request_token(consumer_key, redirect_uri)

Specs

get_request_token(String.t, String.t) ::
  {:ok, Pocketeer.Response.t} |
  {:error, HTTPError.t}

Sends a request to fetch a request_token from Pocket.

Examples

Pocketeer.Auth.get_request_token("1234", "http://example.com")

Parameters:

  • consumer_key: The consumer key used from the Pocket API
  • redirect_uri: URL to redirect when the authorization process has been completed