File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ Before testing, we need to create a client:
45
45
46
46
![ create a client] ( https://user-images.githubusercontent.com/290496/38811988-081814d4-41c6-11e8-88e1-cb6c25a6f82e.png )
47
47
48
+ ### Password flow example
49
+
48
50
Get your ` client_id ` and ` client_secret ` for testing. In this example, we
49
51
have enabled ` password ` grant types, let's try:
50
52
@@ -58,6 +60,27 @@ Because this is an example, every user's password is `valid`. Now you can access
58
60
$ curl -H " Authorization: Bearer ${access_token} " http://127.0.0.1:5000/api/me
59
61
```
60
62
63
+ ### Authorization code flow example
64
+
65
+ To test the authorization code flow, you can just open this URL in your browser.
66
+ ``` bash
67
+ $ open http://127.0.0.1:5000/oauth/authorize? response_type=code& client_id=${client_id} & scope=profile
68
+ ```
69
+
70
+ After granting the authorization, you should be redirected to ` ${redirect_uri}/?code=${code} `
71
+
72
+ Then your app can send the code to the authorization server to get an access token:
73
+
74
+ ``` bash
75
+ $ curl -u ${client_id} :${client_secret} -XPOST http://127.0.0.1:5000/oauth/token -F grant_type=authorization_code -F scope=profile -F code=${code}
76
+ ```
77
+
78
+ Now you can access ` /api/me ` :
79
+
80
+ ``` bash
81
+ $ curl -H " Authorization: Bearer ${access_token} " http://127.0.0.1:5000/api/me
82
+ ```
83
+
61
84
For now, you can read the source in example or follow the long boring tutorial below.
62
85
63
86
** IMPORTANT** : To test implicit grant, you need to ` token_endpoint_auth_method ` to ` none ` .
You can’t perform that action at this time.
0 commit comments