View Source Wpcom.Oauth2 (wpcom.ex v1.0.0)

Interact with WordPress.com and Jetpack sites using OAuth2

See: https://developer.wordpress.com/docs/oauth2

Summary

Types

@type blog_id() :: pos_integer()
@type grant_type() ::
  :authorization_code | :client_credentials | :password | :wpcom_exchange_token
@type scope() :: :auth | :global

Functions

Link to this function

authorize_url(client_id, redirect_uri, scope \\ :auth, blog \\ nil)

View Source
@spec authorize_url(pos_integer(), String.t(), scope(), blog_id() | nil) :: String.t()

Generate a WP.com OAuth2 authorize URL with the given arguments

Response type is forced to "code" as implicit OAuth is bad practice, particularly serverside like this library.

Link to this function

retrieve_token(client_id, client_secret, oauth_code, redirect_uri, grant_type \\ :authorization_code)

View Source
@spec retrieve_token(pos_integer(), String.t(), String.t(), String.t(), grant_type()) ::
  {:ok, Req.Response.t()} | {:error, Exception.t()}

Retrieve an WP.com OAuth2 token

Requires a previously returned auth code.