11 |14 | 15 |To request an access token, the client obtains authorization from the resource owner.
12 | 13 |
{{ username }}, {{ client_id }} would like permission to access your account:
17 |11 |14 | 15 | 16 | 17 | 18 | 19 | 20 |The client makes a request to the token endpoint by sending the following parameters using the "application/x-www-form-urlencoded" format per Appendix B with a character encoding of UTF-8 in the HTTP request entity-body:
12 | 13 |
11 |14 | 15 | 16 | 17 | 18 | 19 | 20 |The client makes a request to the token endpoint by adding the following parameters using the "application/x-www-form-urlencoded" format per Appendix B with a character encoding of UTF-8 in the HTTP request entity-body:
12 | 13 |
11 |14 | 15 | 16 | 17 | 18 | 19 | 20 |The client makes a request to the token endpoint by adding the following parameters using the "application/x-www-form-urlencoded" format per Appendix B with a character encoding of UTF-8 in the HTTP request entity-body:
12 | 13 |
11 |14 | 15 | 16 | 17 | 18 | 19 | 20 |If the authorization server issued a refresh token to the client, the client makes a refresh request to the token endpoint by adding the following parameters using the "application/x-www-form-urlencoded" format per Appendix B with a character encoding of UTF-8 in the HTTP request entity-body:
12 | 13 |
Here we demos some of the basic OAuth2.0 Workflows. Corresponding request and response raw debug message will show in a step-by-step, page-by-page style. Read though routing.yml and DemoController.php to see how we implement it.
11 | 12 |14 |17 | 18 | 19 |The authorization code grant type is used to obtain both access tokens and refresh tokens and is optimized for confidential clients.
15 | 16 |
21 |24 | 25 | 26 |The implicit grant type is used to obtain access tokens (it does not support the issuance of refresh tokens) and is optimized for public clients known to operate a particular redirection URI. These clients are typically implemented in a browser using a scripting language such as JavaScript.
22 | 23 |
28 |31 | 32 | 33 |The resource owner password credentials grant type is suitable in cases where the resource owner has a trust relationship with the client, such as the device operating system or a highly privileged application.
29 | 30 |
35 |38 | 39 |The client can request an access token using only its client credentials (or other supported means of authentication) when the client is requesting access to the protected resources under its control, or those of another resource owner that have been previously arranged with the authorization server (the method of which is beyond the scope of this specification).
36 | 37 |
11 |14 | 15 |The authorization server MUST first verify the identity of the resource owner.
12 | 13 |
11 |14 | 15 | 16 | 17 |The client accesses protected resources by presenting the access token to the resource server.
12 | 13 |
11 |14 | 15 | 16 | 17 |The client accesses protected resources by presenting the access token to the resource server.
12 | 13 |
11 |14 | 15 | 16 | 17 | 18 |The client directs the resource owner to the constructed URI using an HTTP redirection response, or by other means available to it via the user-agent.
12 | 13 |
11 |14 | 15 | 16 | 17 | 18 | 19 |The client directs the resource owner to the constructed URI using an HTTP redirection response, or by other means available to it via the user-agent.
12 | 13 |
11 |14 |The server issuing access tokens to the client after successfully authenticating the resource owner and obtaining authorization.
12 | 13 |
Authorization server's endpoints usually without GUI, but just RESTful API interface. Read though routing.yml to see how we implement it.
15 | 16 |18 |21 | 22 |The authorization process utilizes two authorization server endpoints (HTTP resources):
19 | 20 |
/api/oauth2/authorize
and /demo/authorize
)24 |27 |The authorization endpoint is used to interact with the resource owner and obtain an authorization grant.
25 | 26 |
Authorization endpoint (HTTP Basic Authentication and Form-based Authentication) are protected by Symfony's SecurityBundle in this example. Read though security.yml to see how we implement it.
28 |Direct browser access is possible, authentication request will therefore triggered, and able to login with following testing account:
29 |demousername1
demopassword1
After successful login, by default if access this endpoint without addition parameters, an error message {"error":"invalid_request"}
should be shown in JSON format.
/api/oauth2/token
)37 |40 |The token endpoint is used by the client to obtain an access token by presenting its authorization grant or refresh token.
38 | 39 |
Token endpoint is protected by OAuth2Bundle's AuthBucketOAuth2Bundle in this example. Read though security.yml to see how we implement it.
41 |By default this endpoint shouldn't access by browser directly with GET, else an error message {"error":"invalid_request"}
should be show in JSON format.
For debug purpose, may consider send out POST request to this endpoint by HttpRequester.
43 | 44 |Following endpoints are excluded from RFC6749, but live implementation should consider it.
46 | 47 |/oauth2/login
)Form-based Authentication implemented by Symfony's SecurityBundle in this example. Read though routing.yml and login.html.twig for more information.
49 |This is used for protect above Authorization Endpoints.
50 | 51 |/api/oauth2/debug
)Debug Endpoint clone the idea of Facebook's Debug API Endpoint, return raw information of corresponding access_token
provided. Read though security.yml and routing.yml for more information.
When working with an access token, you may need to check what information is associated with it, such as its user or expiry. To use this endpoint, you can issue a GET/POST request, e.g.:
54 |GET /api/oauth2/debug?access_token={access_token} HTTP/1.1
55 | Host: server.example.com
56 | access_token
: the access token you want to get information aboutThe response of the API call is a JSON array containing a map of fields. For example:
60 |{
61 | "access_token": "5dc0bdbb2f66a842cb46a02b6d559131",
62 | "client_id": "authorization_code_grant",
63 | "expires": 1404641243,
64 | "scope": [
65 | "demoscope1"
66 | ],
67 | "token_type": "bearer",
68 | "username": "demousername1"
69 | }
70 | Remote Resource Server may also utilize this debug endpoint to verfiy the supplied access token.
71 |