OAuth docs:
documented the OAuth authorization flow and how to register your application
Account docs:
documented getting/updating user profile data
documented getting/updating user email data
Docker-DCO-1.1-Signed-off-by: Josh hawn <josh.hawn@docker.com> (github: jlhawn)
| ... | ... |
@@ -3,3 +3,4 @@ This directory holds the authoritative specifications of APIs defined and implem |
| 3 | 3 |
* The remote API by which a docker node can be queried over HTTP |
| 4 | 4 |
* The registry API by which a docker node can download and upload container images for storage and sharing |
| 5 | 5 |
* The index search API by which a docker node can search the public index for images to download |
| 6 |
+* The docker.io OAuth and accounts API which 3rd party services can use to access account information |
| 8 | 9 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,308 @@ |
| 0 |
+:title: docker.io Accounts API |
|
| 1 |
+:description: API Documentation for docker.io accounts. |
|
| 2 |
+:keywords: API, Docker, accounts, REST, documentation |
|
| 3 |
+ |
|
| 4 |
+ |
|
| 5 |
+====================== |
|
| 6 |
+docker.io Accounts API |
|
| 7 |
+====================== |
|
| 8 |
+ |
|
| 9 |
+.. contents:: Table of Contents |
|
| 10 |
+ |
|
| 11 |
+ |
|
| 12 |
+1. Endpoints |
|
| 13 |
+============ |
|
| 14 |
+ |
|
| 15 |
+ |
|
| 16 |
+1.1 Get a single user |
|
| 17 |
+^^^^^^^^^^^^^^^^^^^^^ |
|
| 18 |
+ |
|
| 19 |
+.. http:get:: /api/v1.1/users/:username/ |
|
| 20 |
+ |
|
| 21 |
+ Get profile info for the specified user. |
|
| 22 |
+ |
|
| 23 |
+ :param username: username of the user whose profile info is being requested. |
|
| 24 |
+ |
|
| 25 |
+ :reqheader Authorization: required authentication credentials of either type HTTP Basic or OAuth Bearer Token. |
|
| 26 |
+ |
|
| 27 |
+ :statuscode 200: success, user data returned. |
|
| 28 |
+ :statuscode 401: authentication error. |
|
| 29 |
+ :statuscode 403: permission error, authenticated user must be the user whose data is being requested, OAuth access tokens must have ``profile_read`` scope. |
|
| 30 |
+ :statuscode 404: the specified username does not exist. |
|
| 31 |
+ |
|
| 32 |
+ **Example request**: |
|
| 33 |
+ |
|
| 34 |
+ .. sourcecode:: http |
|
| 35 |
+ |
|
| 36 |
+ GET /api/v1.1/users/janedoe/ HTTP/1.1 |
|
| 37 |
+ Host: www.docker.io |
|
| 38 |
+ Accept: application/json |
|
| 39 |
+ Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= |
|
| 40 |
+ |
|
| 41 |
+ **Example response**: |
|
| 42 |
+ |
|
| 43 |
+ .. sourcecode:: http |
|
| 44 |
+ |
|
| 45 |
+ HTTP/1.1 200 OK |
|
| 46 |
+ Content-Type: application/json |
|
| 47 |
+ |
|
| 48 |
+ {
|
|
| 49 |
+ "id": 2, |
|
| 50 |
+ "username": "janedoe", |
|
| 51 |
+ "url": "", |
|
| 52 |
+ "date_joined": "2014-02-12T17:58:01.431312Z", |
|
| 53 |
+ "type": "User", |
|
| 54 |
+ "full_name": "Jane Doe", |
|
| 55 |
+ "location": "San Francisco, CA", |
|
| 56 |
+ "company": "Success, Inc.", |
|
| 57 |
+ "profile_url": "https://docker.io/", |
|
| 58 |
+ "gravatar_email": "jane.doe+gravatar@example.com", |
|
| 59 |
+ "email": "jane.doe@example.com", |
|
| 60 |
+ "is_active": true |
|
| 61 |
+ } |
|
| 62 |
+ |
|
| 63 |
+ |
|
| 64 |
+1.2 Update a single user |
|
| 65 |
+^^^^^^^^^^^^^^^^^^^^^^^^ |
|
| 66 |
+ |
|
| 67 |
+.. http:patch:: /api/v1.1/users/:username/ |
|
| 68 |
+ |
|
| 69 |
+ Update profile info for the specified user. |
|
| 70 |
+ |
|
| 71 |
+ :param username: username of the user whose profile info is being updated. |
|
| 72 |
+ |
|
| 73 |
+ :jsonparam string full_name: (optional) the new name of the user. |
|
| 74 |
+ :jsonparam string location: (optional) the new location. |
|
| 75 |
+ :jsonparam string company: (optional) the new company of the user. |
|
| 76 |
+ :jsonparam string profile_url: (optional) the new profile url. |
|
| 77 |
+ :jsonparam string gravatar_email: (optional) the new Gravatar email address. |
|
| 78 |
+ |
|
| 79 |
+ :reqheader Authorization: required authentication credentials of either type HTTP Basic or OAuth Bearer Token. |
|
| 80 |
+ :reqheader Content-Type: MIME Type of post data. JSON, url-encoded form data, etc. |
|
| 81 |
+ |
|
| 82 |
+ :statuscode 200: success, user data updated. |
|
| 83 |
+ :statuscode 400: post data validation error. |
|
| 84 |
+ :statuscode 401: authentication error. |
|
| 85 |
+ :statuscode 403: permission error, authenticated user must be the user whose data is being updated, OAuth access tokens must have ``profile_write`` scope. |
|
| 86 |
+ :statuscode 404: the specified username does not exist. |
|
| 87 |
+ |
|
| 88 |
+ **Example request**: |
|
| 89 |
+ |
|
| 90 |
+ .. sourcecode:: http |
|
| 91 |
+ |
|
| 92 |
+ PATCH /api/v1.1/users/janedoe/ HTTP/1.1 |
|
| 93 |
+ Host: www.docker.io |
|
| 94 |
+ Accept: application/json |
|
| 95 |
+ Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= |
|
| 96 |
+ |
|
| 97 |
+ {
|
|
| 98 |
+ "location": "Private Island", |
|
| 99 |
+ "profile_url": "http://janedoe.com/", |
|
| 100 |
+ "company": "Retired", |
|
| 101 |
+ } |
|
| 102 |
+ |
|
| 103 |
+ **Example response**: |
|
| 104 |
+ |
|
| 105 |
+ .. sourcecode:: http |
|
| 106 |
+ |
|
| 107 |
+ HTTP/1.1 200 OK |
|
| 108 |
+ Content-Type: application/json |
|
| 109 |
+ |
|
| 110 |
+ {
|
|
| 111 |
+ "id": 2, |
|
| 112 |
+ "username": "janedoe", |
|
| 113 |
+ "url": "", |
|
| 114 |
+ "date_joined": "2014-02-12T17:58:01.431312Z", |
|
| 115 |
+ "type": "User", |
|
| 116 |
+ "full_name": "Jane Doe", |
|
| 117 |
+ "location": "Private Island", |
|
| 118 |
+ "company": "Retired", |
|
| 119 |
+ "profile_url": "http://janedoe.com/", |
|
| 120 |
+ "gravatar_email": "jane.doe+gravatar@example.com", |
|
| 121 |
+ "email": "jane.doe@example.com", |
|
| 122 |
+ "is_active": true |
|
| 123 |
+ } |
|
| 124 |
+ |
|
| 125 |
+ |
|
| 126 |
+1.3 List email addresses for a user |
|
| 127 |
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
| 128 |
+ |
|
| 129 |
+.. http:get:: /api/v1.1/users/:username/emails/ |
|
| 130 |
+ |
|
| 131 |
+ List email info for the specified user. |
|
| 132 |
+ |
|
| 133 |
+ :param username: username of the user whose profile info is being updated. |
|
| 134 |
+ |
|
| 135 |
+ :reqheader Authorization: required authentication credentials of either type HTTP Basic or OAuth Bearer Token |
|
| 136 |
+ |
|
| 137 |
+ :statuscode 200: success, user data updated. |
|
| 138 |
+ :statuscode 401: authentication error. |
|
| 139 |
+ :statuscode 403: permission error, authenticated user must be the user whose data is being requested, OAuth access tokens must have ``email_read`` scope. |
|
| 140 |
+ :statuscode 404: the specified username does not exist. |
|
| 141 |
+ |
|
| 142 |
+ **Example request**: |
|
| 143 |
+ |
|
| 144 |
+ .. sourcecode:: http |
|
| 145 |
+ |
|
| 146 |
+ GET /api/v1.1/users/janedoe/emails/ HTTP/1.1 |
|
| 147 |
+ Host: www.docker.io |
|
| 148 |
+ Accept: application/json |
|
| 149 |
+ Authorization: Bearer zAy0BxC1wDv2EuF3tGs4HrI6qJp6KoL7nM |
|
| 150 |
+ |
|
| 151 |
+ **Example response**: |
|
| 152 |
+ |
|
| 153 |
+ .. sourcecode:: http |
|
| 154 |
+ |
|
| 155 |
+ HTTP/1.1 200 OK |
|
| 156 |
+ Content-Type: application/json |
|
| 157 |
+ |
|
| 158 |
+ [ |
|
| 159 |
+ {
|
|
| 160 |
+ "email": "jane.doe@example.com", |
|
| 161 |
+ "verified": true, |
|
| 162 |
+ "primary": true |
|
| 163 |
+ } |
|
| 164 |
+ ] |
|
| 165 |
+ |
|
| 166 |
+ |
|
| 167 |
+1.4 Add email address for a user |
|
| 168 |
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
| 169 |
+ |
|
| 170 |
+.. http:post:: /api/v1.1/users/:username/emails/ |
|
| 171 |
+ |
|
| 172 |
+ Add a new email address to the specified user's account. The email address |
|
| 173 |
+ must be verified separately, a confirmation email is not automatically sent. |
|
| 174 |
+ |
|
| 175 |
+ :jsonparam string email: email address to be added. |
|
| 176 |
+ |
|
| 177 |
+ :reqheader Authorization: required authentication credentials of either type HTTP Basic or OAuth Bearer Token. |
|
| 178 |
+ :reqheader Content-Type: MIME Type of post data. JSON, url-encoded form data, etc. |
|
| 179 |
+ |
|
| 180 |
+ :statuscode 201: success, new email added. |
|
| 181 |
+ :statuscode 400: data validation error. |
|
| 182 |
+ :statuscode 401: authentication error. |
|
| 183 |
+ :statuscode 403: permission error, authenticated user must be the user whose data is being requested, OAuth access tokens must have ``email_write`` scope. |
|
| 184 |
+ :statuscode 404: the specified username does not exist. |
|
| 185 |
+ |
|
| 186 |
+ **Example request**: |
|
| 187 |
+ |
|
| 188 |
+ .. sourcecode:: http |
|
| 189 |
+ |
|
| 190 |
+ POST /api/v1.1/users/janedoe/emails/ HTTP/1.1 |
|
| 191 |
+ Host: www.docker.io |
|
| 192 |
+ Accept: application/json |
|
| 193 |
+ Content-Type: application/json |
|
| 194 |
+ Authorization: Bearer zAy0BxC1wDv2EuF3tGs4HrI6qJp6KoL7nM |
|
| 195 |
+ |
|
| 196 |
+ {
|
|
| 197 |
+ "email": "jane.doe+other@example.com" |
|
| 198 |
+ } |
|
| 199 |
+ |
|
| 200 |
+ **Example response**: |
|
| 201 |
+ |
|
| 202 |
+ .. sourcecode:: http |
|
| 203 |
+ |
|
| 204 |
+ HTTP/1.1 201 Created |
|
| 205 |
+ Content-Type: application/json |
|
| 206 |
+ |
|
| 207 |
+ {
|
|
| 208 |
+ "email": "jane.doe+other@example.com", |
|
| 209 |
+ "verified": false, |
|
| 210 |
+ "primary": false |
|
| 211 |
+ } |
|
| 212 |
+ |
|
| 213 |
+ |
|
| 214 |
+1.5 Update an email address for a user |
|
| 215 |
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
| 216 |
+ |
|
| 217 |
+.. http:patch:: /api/v1.1/users/:username/emails/ |
|
| 218 |
+ |
|
| 219 |
+ Update an email address for the specified user to either verify an email |
|
| 220 |
+ address or set it as the primary email for the user. You cannot use this |
|
| 221 |
+ endpoint to un-verify an email address. You cannot use this endpoint to |
|
| 222 |
+ unset the primary email, only set another as the primary. |
|
| 223 |
+ |
|
| 224 |
+ :param username: username of the user whose email info is being updated. |
|
| 225 |
+ |
|
| 226 |
+ :jsonparam string email: the email address to be updated. |
|
| 227 |
+ :jsonparam boolean verified: (optional) whether the email address is verified, must be ``true`` or absent. |
|
| 228 |
+ :jsonparam boolean primary: (optional) whether to set the email address as the primary email, must be ``true`` or absent. |
|
| 229 |
+ |
|
| 230 |
+ :reqheader Authorization: required authentication credentials of either type HTTP Basic or OAuth Bearer Token. |
|
| 231 |
+ :reqheader Content-Type: MIME Type of post data. JSON, url-encoded form data, etc. |
|
| 232 |
+ |
|
| 233 |
+ :statuscode 200: success, user's email updated. |
|
| 234 |
+ :statuscode 400: data validation error. |
|
| 235 |
+ :statuscode 401: authentication error. |
|
| 236 |
+ :statuscode 403: permission error, authenticated user must be the user whose data is being updated, OAuth access tokens must have ``email_write`` scope. |
|
| 237 |
+ :statuscode 404: the specified username or email address does not exist. |
|
| 238 |
+ |
|
| 239 |
+ **Example request**: |
|
| 240 |
+ |
|
| 241 |
+ Once you have independently verified an email address. |
|
| 242 |
+ |
|
| 243 |
+ .. sourcecode:: http |
|
| 244 |
+ |
|
| 245 |
+ PATCH /api/v1.1/users/janedoe/emails/ HTTP/1.1 |
|
| 246 |
+ Host: www.docker.io |
|
| 247 |
+ Accept: application/json |
|
| 248 |
+ Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= |
|
| 249 |
+ |
|
| 250 |
+ {
|
|
| 251 |
+ "email": "jane.doe+other@example.com", |
|
| 252 |
+ "verified": true, |
|
| 253 |
+ } |
|
| 254 |
+ |
|
| 255 |
+ **Example response**: |
|
| 256 |
+ |
|
| 257 |
+ .. sourcecode:: http |
|
| 258 |
+ |
|
| 259 |
+ HTTP/1.1 200 OK |
|
| 260 |
+ Content-Type: application/json |
|
| 261 |
+ |
|
| 262 |
+ {
|
|
| 263 |
+ "email": "jane.doe+other@example.com", |
|
| 264 |
+ "verified": true, |
|
| 265 |
+ "primary": false |
|
| 266 |
+ } |
|
| 267 |
+ |
|
| 268 |
+ |
|
| 269 |
+1.6 Delete email address for a user |
|
| 270 |
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
| 271 |
+ |
|
| 272 |
+.. http:delete:: /api/v1.1/users/:username/emails/ |
|
| 273 |
+ |
|
| 274 |
+ Delete an email address from the specified user's account. You cannot |
|
| 275 |
+ delete a user's primary email address. |
|
| 276 |
+ |
|
| 277 |
+ :jsonparam string email: email address to be deleted. |
|
| 278 |
+ |
|
| 279 |
+ :reqheader Authorization: required authentication credentials of either type HTTP Basic or OAuth Bearer Token. |
|
| 280 |
+ :reqheader Content-Type: MIME Type of post data. JSON, url-encoded form data, etc. |
|
| 281 |
+ |
|
| 282 |
+ :statuscode 204: success, email address removed. |
|
| 283 |
+ :statuscode 400: validation error. |
|
| 284 |
+ :statuscode 401: authentication error. |
|
| 285 |
+ :statuscode 403: permission error, authenticated user must be the user whose data is being requested, OAuth access tokens must have ``email_write`` scope. |
|
| 286 |
+ :statuscode 404: the specified username or email address does not exist. |
|
| 287 |
+ |
|
| 288 |
+ **Example request**: |
|
| 289 |
+ |
|
| 290 |
+ .. sourcecode:: http |
|
| 291 |
+ |
|
| 292 |
+ DELETE /api/v1.1/users/janedoe/emails/ HTTP/1.1 |
|
| 293 |
+ Host: www.docker.io |
|
| 294 |
+ Accept: application/json |
|
| 295 |
+ Content-Type: application/json |
|
| 296 |
+ Authorization: Bearer zAy0BxC1wDv2EuF3tGs4HrI6qJp6KoL7nM |
|
| 297 |
+ |
|
| 298 |
+ {
|
|
| 299 |
+ "email": "jane.doe+other@example.com" |
|
| 300 |
+ } |
|
| 301 |
+ |
|
| 302 |
+ **Example response**: |
|
| 303 |
+ |
|
| 304 |
+ .. sourcecode:: http |
|
| 305 |
+ |
|
| 306 |
+ HTTP/1.1 204 NO CONTENT |
|
| 307 |
+ Content-Length: 0 |
| 0 | 308 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,233 @@ |
| 0 |
+:title: docker.io OAuth API |
|
| 1 |
+:description: API Documentation for docker.io's OAuth flow. |
|
| 2 |
+:keywords: API, Docker, oauth, REST, documentation |
|
| 3 |
+ |
|
| 4 |
+ |
|
| 5 |
+=================== |
|
| 6 |
+docker.io OAuth API |
|
| 7 |
+=================== |
|
| 8 |
+ |
|
| 9 |
+.. contents:: Table of Contents |
|
| 10 |
+ |
|
| 11 |
+ |
|
| 12 |
+1. Brief introduction |
|
| 13 |
+===================== |
|
| 14 |
+ |
|
| 15 |
+Some docker.io API requests will require an access token to authenticate. To |
|
| 16 |
+get an access token for a user, that user must first grant your application |
|
| 17 |
+access to their docker.io account. In order for them to grant your application |
|
| 18 |
+access you must first register your application. |
|
| 19 |
+ |
|
| 20 |
+Before continuing, we encourage you to familiarize yourself with |
|
| 21 |
+`The OAuth 2.0 Authorization Framework <http://tools.ietf.org/html/rfc6749>`_. |
|
| 22 |
+ |
|
| 23 |
+ |
|
| 24 |
+2. Register Your Application |
|
| 25 |
+============================ |
|
| 26 |
+ |
|
| 27 |
+You will need to register your application with docker.io before users will |
|
| 28 |
+be able to grant your application access to their account information. We |
|
| 29 |
+are currently only allowing applications selectively. To request registration |
|
| 30 |
+of your application send an email to support-accounts@docker.com with the |
|
| 31 |
+following information: |
|
| 32 |
+ |
|
| 33 |
+- The name of your application |
|
| 34 |
+- A description of your application and the service it will provide |
|
| 35 |
+ to docker.io users. |
|
| 36 |
+- A list of one or more redirect URIs that we will use for redirecting |
|
| 37 |
+ authorization requests to your application. These are used in the step |
|
| 38 |
+ of getting an Authorization Code. |
|
| 39 |
+ |
|
| 40 |
+When your application is approved you will receive a response from the |
|
| 41 |
+docker.io team with your ``client_id`` and ``client_secret`` which your |
|
| 42 |
+application will use in the steps of getting an Authorization Code and getting |
|
| 43 |
+an Access Token. |
|
| 44 |
+ |
|
| 45 |
+ |
|
| 46 |
+3. Endpoints |
|
| 47 |
+============ |
|
| 48 |
+ |
|
| 49 |
+3.1 Get an Authorization Code |
|
| 50 |
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
| 51 |
+ |
|
| 52 |
+Once You have registered you are ready to start integrating docker.io accounts |
|
| 53 |
+into your application! The process is usually started by a user following a |
|
| 54 |
+link in your application to an OAuth Authorization endpoint. |
|
| 55 |
+ |
|
| 56 |
+.. http:get:: /api/v1.1/o/authorize/ |
|
| 57 |
+ |
|
| 58 |
+ Request that a docker.io user authorize your application. If the user is |
|
| 59 |
+ not already logged in, they will be prompted to login. The user is then |
|
| 60 |
+ presented with a form to authorize your application for the requested |
|
| 61 |
+ access scope. On submission, the user will be redirected to the specified |
|
| 62 |
+ ``redirect_uri`` with an Authorization Code. |
|
| 63 |
+ |
|
| 64 |
+ :query client_id: The ``client_id`` given to your application at |
|
| 65 |
+ registration. |
|
| 66 |
+ :query response_type: MUST be set to ``code``. This specifies that you |
|
| 67 |
+ would like an Authorization Code returned. |
|
| 68 |
+ :query redirect_uri: The URI to redirect back to after the user has |
|
| 69 |
+ authorized your application. If omitted, the first of your registered |
|
| 70 |
+ ``response_uris`` is used. If included, it must be one of the URIs |
|
| 71 |
+ which were submitted when registering your application. |
|
| 72 |
+ :query scope: The extent of access permissions you are requesting. |
|
| 73 |
+ Currently, the scope options are ``profile_read``, ``profile_write``, |
|
| 74 |
+ ``email_read``, and ``email_write``. Scopes must be separated by a |
|
| 75 |
+ space. If omitted, the default scopes ``profile_read email_read`` are |
|
| 76 |
+ used. |
|
| 77 |
+ :query state: (Recommended) Used by your application to maintain state |
|
| 78 |
+ between the authorization request and callback to protect against CSRF |
|
| 79 |
+ attacks. |
|
| 80 |
+ |
|
| 81 |
+ **Example Request** |
|
| 82 |
+ |
|
| 83 |
+ Asking the user for authorization. |
|
| 84 |
+ |
|
| 85 |
+ .. sourcecode:: http |
|
| 86 |
+ |
|
| 87 |
+ GET /api/v1.1/o/authorize/?client_id=TestClientID&response_type=code&redirect_uri=http%3A//my.app/auth_complete/&scope=profile_read%20email_read&state=abc123 HTTP/1.1 |
|
| 88 |
+ Host: www.docker.io |
|
| 89 |
+ |
|
| 90 |
+ **Authorization Page** |
|
| 91 |
+ |
|
| 92 |
+ When the user follows a link, making the above GET request, they will be |
|
| 93 |
+ asked to login to their docker.io account if they are not already and then |
|
| 94 |
+ be presented with the following authorization prompt which asks the user |
|
| 95 |
+ to authorize your application with a description of the requested scopes. |
|
| 96 |
+ |
|
| 97 |
+ .. image:: _static/io_oauth_authorization_page.jpg |
|
| 98 |
+ |
|
| 99 |
+ Once the user allows or denies your Authorization Request the user will be |
|
| 100 |
+ redirected back to your application. Included in that request will be the |
|
| 101 |
+ following query parameters: |
|
| 102 |
+ |
|
| 103 |
+ ``code`` |
|
| 104 |
+ The Authorization code generated by the docker.io authorization server. |
|
| 105 |
+ Present it again to request an Access Token. This code expires in 60 |
|
| 106 |
+ seconds. |
|
| 107 |
+ |
|
| 108 |
+ ``state`` |
|
| 109 |
+ If the ``state`` parameter was present in the authorization request this |
|
| 110 |
+ will be the exact value received from that request. |
|
| 111 |
+ |
|
| 112 |
+ ``error`` |
|
| 113 |
+ An error message in the event of the user denying the authorization or |
|
| 114 |
+ some other kind of error with the request. |
|
| 115 |
+ |
|
| 116 |
+ |
|
| 117 |
+3.2 Get an Access Token |
|
| 118 |
+^^^^^^^^^^^^^^^^^^^^^^^ |
|
| 119 |
+ |
|
| 120 |
+Once the user has authorized your application, a request will be made to your |
|
| 121 |
+application's specified ``redirect_uri`` which includes a ``code`` parameter |
|
| 122 |
+that you must then use to get an Access Token. |
|
| 123 |
+ |
|
| 124 |
+.. http:post:: /api/v1.1/o/token/ |
|
| 125 |
+ |
|
| 126 |
+ Submit your newly granted Authorization Code and your application's |
|
| 127 |
+ credentials to receive an Access Token and Refresh Token. The code is valid |
|
| 128 |
+ for 60 seconds and cannot be used more than once. |
|
| 129 |
+ |
|
| 130 |
+ :reqheader Authorization: HTTP basic authentication using your |
|
| 131 |
+ application's ``client_id`` and ``client_secret`` |
|
| 132 |
+ |
|
| 133 |
+ :form grant_type: MUST be set to ``authorization_code`` |
|
| 134 |
+ :form code: The authorization code received from the user's redirect |
|
| 135 |
+ request. |
|
| 136 |
+ :form redirect_uri: The same ``redirect_uri`` used in the authentication |
|
| 137 |
+ request. |
|
| 138 |
+ |
|
| 139 |
+ **Example Request** |
|
| 140 |
+ |
|
| 141 |
+ Using an authorization code to get an access token. |
|
| 142 |
+ |
|
| 143 |
+ .. sourcecode:: http |
|
| 144 |
+ |
|
| 145 |
+ POST /api/v1.1/o/token/ HTTP/1.1 |
|
| 146 |
+ Host: www.docker.io |
|
| 147 |
+ Authorization: Basic VGVzdENsaWVudElEOlRlc3RDbGllbnRTZWNyZXQ= |
|
| 148 |
+ Accept: application/json |
|
| 149 |
+ Content-Type: application/json |
|
| 150 |
+ |
|
| 151 |
+ {
|
|
| 152 |
+ "grant_type": "code", |
|
| 153 |
+ "code": "YXV0aG9yaXphdGlvbl9jb2Rl", |
|
| 154 |
+ "redirect_uri": "http://my.app/auth_complete/" |
|
| 155 |
+ } |
|
| 156 |
+ |
|
| 157 |
+ **Example Response** |
|
| 158 |
+ |
|
| 159 |
+ .. sourcecode:: http |
|
| 160 |
+ |
|
| 161 |
+ HTTP/1.1 200 OK |
|
| 162 |
+ Content-Type: application/json;charset=UTF-8 |
|
| 163 |
+ |
|
| 164 |
+ {
|
|
| 165 |
+ "username": "janedoe", |
|
| 166 |
+ "user_id": 42, |
|
| 167 |
+ "access_token": "t6k2BqgRw59hphQBsbBoPPWLqu6FmS", |
|
| 168 |
+ "expires_in": 15552000, |
|
| 169 |
+ "token_type": "Bearer", |
|
| 170 |
+ "scope": "profile_read email_read", |
|
| 171 |
+ "refresh_token": "hJDhLH3cfsUrQlT4MxA6s8xAFEqdgc" |
|
| 172 |
+ } |
|
| 173 |
+ |
|
| 174 |
+ In the case of an error, there will be a non-200 HTTP Status and and data |
|
| 175 |
+ detailing the error. |
|
| 176 |
+ |
|
| 177 |
+ |
|
| 178 |
+3.3 Refresh a Token |
|
| 179 |
+^^^^^^^^^^^^^^^^^^^ |
|
| 180 |
+ |
|
| 181 |
+Once the Access Token expires you can use your ``refresh_token`` to have |
|
| 182 |
+docker.io issue your application a new Access Token, if the user has not |
|
| 183 |
+revoked access from your application. |
|
| 184 |
+ |
|
| 185 |
+.. http:post:: /api/v1.1/o/token/ |
|
| 186 |
+ |
|
| 187 |
+ Submit your ``refresh_token`` and application's credentials to receive a |
|
| 188 |
+ new Access Token and Refresh Token. The ``refresh_token`` can be used |
|
| 189 |
+ only once. |
|
| 190 |
+ |
|
| 191 |
+ :reqheader Authorization: HTTP basic authentication using your |
|
| 192 |
+ application's ``client_id`` and ``client_secret`` |
|
| 193 |
+ |
|
| 194 |
+ :form grant_type: MUST be set to ``refresh_token`` |
|
| 195 |
+ :form refresh_token: The ``refresh_token`` which was issued to your |
|
| 196 |
+ application. |
|
| 197 |
+ :form scope: (optional) The scope of the access token to be returned. |
|
| 198 |
+ Must not include any scope not originally granted by the user and if |
|
| 199 |
+ omitted is treated as equal to the scope originally granted. |
|
| 200 |
+ |
|
| 201 |
+ **Example Response** |
|
| 202 |
+ |
|
| 203 |
+ .. sourcecode:: http |
|
| 204 |
+ |
|
| 205 |
+ HTTP/1.1 200 OK |
|
| 206 |
+ Content-Type: application/json;charset=UTF-8 |
|
| 207 |
+ |
|
| 208 |
+ {
|
|
| 209 |
+ "username": "janedoe", |
|
| 210 |
+ "user_id": 42, |
|
| 211 |
+ "access_token": "t6k2BqgRw59hphQBsbBoPPWLqu6FmS", |
|
| 212 |
+ "expires_in": 15552000, |
|
| 213 |
+ "token_type": "Bearer", |
|
| 214 |
+ "scope": "profile_read email_read", |
|
| 215 |
+ "refresh_token": "hJDhLH3cfsUrQlT4MxA6s8xAFEqdgc" |
|
| 216 |
+ } |
|
| 217 |
+ |
|
| 218 |
+ In the case of an error, there will be a non-200 HTTP Status and and data |
|
| 219 |
+ detailing the error. |
|
| 220 |
+ |
|
| 221 |
+ |
|
| 222 |
+4. Use an Access Token with the API |
|
| 223 |
+=================================== |
|
| 224 |
+ |
|
| 225 |
+Many of the docker.io API requests will require a Authorization request header |
|
| 226 |
+field. Simply ensure you add this header with "Bearer <``access_token``>": |
|
| 227 |
+ |
|
| 228 |
+.. sourcecode:: http |
|
| 229 |
+ |
|
| 230 |
+ GET /api/v1.1/resource HTTP/1.1 |
|
| 231 |
+ Host: docker.io |
|
| 232 |
+ Authorization: Bearer 2YotnFZFEjr1zCsicMWpAA |