Erlang OAuth 2.0 implementation
This library is designed to simplify the implementation of the server side of OAuth2 (http://tools.ietf.org/html/rfc6749).appctx() = term()
auth() = #a{client = undefined | term(), resowner = undefined | term(), scope = scope(), ttl = non_neg_integer()}
client() = any()
Opaque Client Object
context() = proplists:proplist()
error() = access_denied | invalid_client | invalid_grant | invalid_request | invalid_authorization | invalid_scope | unauthorized_client | unsupported_grant_type | unsupported_response_type | server_error | temporarily_unavailable
lifetime() = non_neg_integer()
rediruri() = any()
Opaque Redirection URI
response() = oauth2_response:response()
scope() = [binary()] | binary()
token() = binary()
user() = any()
Opaque User Object
| authorize_client_credentials/3 | Validates a request for an access token from client's credentials. |
| authorize_code_grant/4 | Validates a request for an access token from an authorization code. |
| authorize_code_request/5 | Validates a request for an authorization code from client and resource owner's credentials. |
| authorize_password/3 | Validates a request for an access token from resource owner's credentials. |
| authorize_password/4 | Validates a request for an access token from client and resource owner's credentials. |
| authorize_password/5 | Validates a request for an access token from client and resource owner's credentials. |
| issue_code/2 | Issues an authorization code from an authorization. |
| issue_token/2 | Issues an access token without refresh token from an authorization. |
| issue_token_and_refresh/2 | Issues access and refresh tokens from an authorization. |
| refresh_access_token/4 | Validates a request for an access token from a refresh token, issuing a new access token if valid. |
| verify_access_code/2 | Verifies an access code AccessCode, returning its associated context if successful. |
| verify_access_code/3 | Verifies an access code AccessCode and it's corresponding Identity, returning its associated context if successful. |
| verify_access_token/2 | Verifies an access token AccessToken, returning its associated context if successful. |
authorize_client_credentials(Client::client(), Scope0::scope(), Ctx0::appctx()) -> {ok, {appctx(), auth()}} | {error, error()}
Validates a request for an access token from client's credentials. Use it to implement the following steps of RFC 6749: - 4.4.2. Client Credentials Grant > Access Token Request.
authorize_code_grant(Client::client(), Code::binary(), RedirUri::rediruri(), Ctx0::appctx()) -> {ok, {appctx(), auth()}} | {error, error()}
Validates a request for an access token from an authorization code. Use it to implement the following steps of RFC 6749: - 4.1.3. Authorization Code Grant > Access Token Request.
authorize_code_request(User::user(), Client::client(), RedirUri::rediruri(), Scope::scope(), Ctx0::appctx()) -> {ok, {appctx(), auth()}} | {error, error()}
Validates a request for an authorization code from client and resource owner's credentials. Use it to implement the following steps of RFC 6749: - 4.1.1. Authorization Code Grant > Authorization Request.
authorize_password(User::user(), Scope::scope(), Ctx0::appctx()) -> {ok, {appctx(), auth()}} | {error, error()}
Validates a request for an access token from resource owner's credentials. Use it to implement the following steps of RFC 6749: - 4.3.2. Resource Owner Password Credentials Grant > Access Token Request, when the client is public.
authorize_password(User::user(), Client::client(), Scope::scope(), Ctx0::appctx()) -> {ok, {appctx(), auth()}} | {error, error()}
Validates a request for an access token from client and resource owner's credentials. Use it to implement the following steps of RFC 6749: - 4.3.2. Resource Owner Password Credentials Grant > Access Token Request, when the client is confidential.
authorize_password(User::user(), Client::client(), RedirUri::rediruri(), Scope::scope(), Ctx0::appctx()) -> {ok, {appctx(), auth()}} | {error, error()}
Validates a request for an access token from client and resource owner's credentials. Use it to implement the following steps of RFC 6749: - 4.2.1. Implicit Grant > Authorization Request, when the client is public.
issue_code(A::auth(), Ctx0::appctx()) -> {ok, {appctx(), response()}}
Issues an authorization code from an authorization. Use it to implement the following steps of RFC 6749: - 4.1.2. Authorization Code Grant > Authorization Response, with the result of authorize_code_request/6.
issue_token(A::auth(), Ctx0::appctx()) -> {ok, {appctx(), response()}}
Issues an access token without refresh token from an authorization. Use it to implement the following steps of RFC 6749: - 4.1.4. Authorization Code Grant > Authorization Response, with the result of authorize_code_grant/5 when no refresh token must be issued. - 4.2.2. Implicit Grant > Access Token Response, with the result of authorize_password/7. - 4.3.3. Resource Owner Password Credentials Grant > Access Token Response, with the result of authorize_password/4 or authorize_password/6 when the client is public or no refresh token must be issued. - 4.4.3. Client Credentials Grant > Access Token Response, with the result of authorize_client_credentials/4.
issue_token_and_refresh(A::auth(), Ctx::appctx()) -> {ok, {appctx(), response()}} | {error, invalid_authorization}
Issues access and refresh tokens from an authorization. Use it to implement the following steps of RFC 6749: - 4.1.4. Authorization Code Grant > Access Token Response, with the result of authorize_code_grant/5 when a refresh token must be issued. - 4.3.3. Resource Owner Password Credentials Grant > Access Token Response, with the result of authorize_password/6 when the client is confidential and a refresh token must be issued.
refresh_access_token(Client::client(), RefreshToken::token(), Scope::scope(), Ctx0::appctx()) -> {ok, {appctx(), response()}} | {error, error()}
Validates a request for an access token from a refresh token, issuing a new access token if valid. Use it to implement the following steps of RFC 6749: - 6. Refreshing an Access Token.
verify_access_code(AccessCode::token(), Ctx0::appctx()) -> {ok, {appctx(), context()}} | {error, error()}
Verifies an access code AccessCode, returning its associated context if successful. Otherwise, an OAuth2 error code is returned.
verify_access_code(AccessCode::token(), Client::client(), Ctx0::appctx()) -> {ok, {appctx(), context()}} | {error, error()}
Verifies an access code AccessCode and it's corresponding Identity, returning its associated context if successful. Otherwise, an OAuth2 error code is returned.
verify_access_token(AccessToken::token(), Ctx0::appctx()) -> {ok, {appctx(), context()}} | {error, error()}
Verifies an access token AccessToken, returning its associated context if successful. Otherwise, an OAuth2 error code is returned.
Generated by EDoc