idnits 2.17.1 draft-ietf-oauth-v2-05.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document date (May 13, 2010) is 5096 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Unused Reference: 'NIST FIPS-180-3' is defined on line 2303, but no explicit reference was found in the text == Unused Reference: 'RFC3447' is defined on line 2332, but no explicit reference was found in the text == Unused Reference: 'RFC3629' is defined on line 2336, but no explicit reference was found in the text == Unused Reference: 'I-D.hammer-oauth' is defined on line 2354, but no explicit reference was found in the text == Unused Reference: 'I-D.hardt-oauth' is defined on line 2358, but no explicit reference was found in the text == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p1-messaging-09 -- Possible downref: Non-RFC (?) normative reference: ref. 'NIST FIPS-180-3' ** Downref: Normative reference to an Informational RFC: RFC 2104 ** Obsolete normative reference: RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) ** Obsolete normative reference: RFC 2617 (Obsoleted by RFC 7235, RFC 7615, RFC 7616, RFC 7617) ** Obsolete normative reference: RFC 2818 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 3023 (Obsoleted by RFC 7303) ** Obsolete normative reference: RFC 3447 (Obsoleted by RFC 8017) ** Obsolete normative reference: RFC 4627 (Obsoleted by RFC 7158, RFC 7159) Summary: 7 errors (**), 0 flaws (~~), 8 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group E. Hammer-Lahav, Ed. 3 Internet-Draft Yahoo! 4 Intended status: Standards Track D. Recordon 5 Expires: November 14, 2010 Facebook 6 D. Hardt 7 May 13, 2010 9 The OAuth 2.0 Protocol 10 draft-ietf-oauth-v2-05 12 Abstract 14 This specification describes the OAuth 2.0 protocol. OAuth provides 15 a method for making authenticated HTTP requests using a token - an 16 identifier used to denote an access grant with specific scope, 17 duration, and other attributes. Tokens are issued to third-party 18 clients by an authorization server with the approval of the resource 19 owner. OAuth defines multiple flows for obtaining a token to support 20 a wide range of client types and user experience. 22 Status of this Memo 24 This Internet-Draft is submitted in full conformance with the 25 provisions of BCP 78 and BCP 79. 27 Internet-Drafts are working documents of the Internet Engineering 28 Task Force (IETF). Note that other groups may also distribute 29 working documents as Internet-Drafts. The list of current Internet- 30 Drafts is at http://datatracker.ietf.org/drafts/current/. 32 Internet-Drafts are draft documents valid for a maximum of six months 33 and may be updated, replaced, or obsoleted by other documents at any 34 time. It is inappropriate to use Internet-Drafts as reference 35 material or to cite them other than as "work in progress." 37 This Internet-Draft will expire on November 14, 2010. 39 Copyright Notice 41 Copyright (c) 2010 IETF Trust and the persons identified as the 42 document authors. All rights reserved. 44 This document is subject to BCP 78 and the IETF Trust's Legal 45 Provisions Relating to IETF Documents 46 (http://trustee.ietf.org/license-info) in effect on the date of 47 publication of this document. Please review these documents 48 carefully, as they describe your rights and restrictions with respect 49 to this document. Code Components extracted from this document must 50 include Simplified BSD License text as described in Section 4.e of 51 the Trust Legal Provisions and are provided without warranty as 52 described in the Simplified BSD License. 54 Table of Contents 56 1. Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 57 2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 58 2.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 5 59 2.2. Overview . . . . . . . . . . . . . . . . . . . . . . . . . 6 60 2.3. Example . . . . . . . . . . . . . . . . . . . . . . . . . 8 61 2.4. Notational Conventions . . . . . . . . . . . . . . . . . . 8 62 2.5. Conformance . . . . . . . . . . . . . . . . . . . . . . . 8 63 3. Obtaining an Access Token . . . . . . . . . . . . . . . . . . 9 64 3.1. Client Credentials . . . . . . . . . . . . . . . . . . . . 9 65 3.2. End-User Endpoint . . . . . . . . . . . . . . . . . . . . 9 66 3.3. Token Endpoint . . . . . . . . . . . . . . . . . . . . . . 10 67 3.3.1. Client Authentication . . . . . . . . . . . . . . . . 11 68 3.3.2. Response Format . . . . . . . . . . . . . . . . . . . 12 69 3.4. Flow Parameters . . . . . . . . . . . . . . . . . . . . . 14 70 3.5. User-Agent Flow . . . . . . . . . . . . . . . . . . . . . 15 71 3.5.1. Client Requests Authorization . . . . . . . . . . . . 16 72 3.5.2. Client Extracts Access Token . . . . . . . . . . . . . 19 73 3.6. Web Server Flow . . . . . . . . . . . . . . . . . . . . . 20 74 3.6.1. Client Requests Authorization . . . . . . . . . . . . 21 75 3.6.2. Client Requests Access Token . . . . . . . . . . . . . 24 76 3.7. Device Flow . . . . . . . . . . . . . . . . . . . . . . . 25 77 3.7.1. Client Requests Authorization . . . . . . . . . . . . 27 78 3.7.2. Client Requests Access Token . . . . . . . . . . . . . 29 79 3.8. Username and Password Flow . . . . . . . . . . . . . . . . 31 80 3.8.1. Client Requests Access Token . . . . . . . . . . . . . 33 81 3.9. Client Credentials Flow . . . . . . . . . . . . . . . . . 35 82 3.9.1. Client Requests Access Token . . . . . . . . . . . . . 35 83 3.10. Assertion Flow . . . . . . . . . . . . . . . . . . . . . . 37 84 3.10.1. Client Requests Access Token . . . . . . . . . . . . . 38 85 4. Refreshing an Access Token . . . . . . . . . . . . . . . . . . 40 86 5. Accessing a Protected Resource . . . . . . . . . . . . . . . . 42 87 5.1. The Authorization Request Header . . . . . . . . . . . . . 43 88 5.2. Bearer Token Requests . . . . . . . . . . . . . . . . . . 44 89 5.2.1. URI Query Parameter . . . . . . . . . . . . . . . . . 45 90 5.2.2. Form-Encoded Body Parameter . . . . . . . . . . . . . 45 91 5.3. Cryptographic Tokens Requests . . . . . . . . . . . . . . 46 92 5.3.1. The 'hmac-sha256' Algorithm . . . . . . . . . . . . . 47 93 6. Identifying a Protected Resource . . . . . . . . . . . . . . . 50 94 6.1. The WWW-Authenticate Response Header . . . . . . . . . . . 50 95 7. Security Considerations . . . . . . . . . . . . . . . . . . . 51 96 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 51 97 9. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 52 98 Appendix A. Differences from OAuth 1.0a . . . . . . . . . . . . . 52 99 Appendix B. Document History . . . . . . . . . . . . . . . . . . 52 100 10. References . . . . . . . . . . . . . . . . . . . . . . . . . . 53 101 10.1. Normative References . . . . . . . . . . . . . . . . . . . 53 102 10.2. Informative References . . . . . . . . . . . . . . . . . . 55 103 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 55 105 1. Authors 107 This specification was authored with the participation and based on 108 the work of Allen Tom (Yahoo!), Brian Eaton (Google), Brent Goldman 109 (Facebook), Luke Shepard (Facebook), Raffi Krikorian (Twitter), and 110 Yaron Goland (Microsoft). 112 2. Introduction 114 With the increasing use of distributed web services and cloud 115 computing, third-party applications require access to server-hosted 116 resources. These resources are usually protected and require 117 authentication using the resource owner's credentials (typically a 118 username and password). In the traditional client-server 119 authentication model, a client accessing a protected resource on a 120 server presents the resource owner's credentials in order to 121 authenticate and gain access. 123 Resource owners should not be required to share their credentials 124 when granting third-party applications access to their protected 125 resources. They should also have the ability to restrict access to a 126 limited subset of the resources they control, to limit access 127 duration, or to limit access to the HTTP methods supported by these 128 resources. 130 OAuth provides a method for making authenticated HTTP requests using 131 a token - an identifier used to denote an access grant with specific 132 scope, duration, and other attributes. Tokens are issued to third- 133 party clients by an authorization server with the approval of the 134 resource owner. Instead of sharing their credentials with the 135 client, resource owners grant access by authenticating directly with 136 the authorization server which in turn issues a token to the client. 137 The client uses the token (and optional secret) to authenticate with 138 the resource server and gain access. 140 For example, a web user (resource owner) can grant a printing service 141 (client) access to her protected photos stored at a photo sharing 142 service (resource server), without sharing her username and password 143 with the printing service. Instead, she authenticates directly with 144 the photo sharing service (authorization server) which issues the 145 printing service delegation-specific credentials (token). 147 This specification defines the use of OAuth over HTTP [RFC2616] (or 148 HTTP over TLS 1.0 as defined by [RFC2818]. Other specifications may 149 extend it for use with other transport protocols. 151 2.1. Terminology 153 resource server 154 An HTTP [RFC2616] server capable of accepting authenticated 155 resource requests using the OAuth protocol. 157 protected resource 158 An access-restricted resource which can be obtained from a 159 resource server using an OAuth-authenticated request. 161 client 162 An HTTP client capable of making authenticated requests for 163 protected resources using the OAuth protocol. 165 resource owner 166 An entity capable of granting access to a protected resource. 168 end-user 169 A human resource owner. 171 access token 172 A unique identifier used by the client to make authenticated 173 requests on behalf of the resource owner. Access tokens may 174 have a matching secret. 176 bearer token An access token without a matching secret, used to 177 obtain access to a protected resource by simply presenting the 178 access token as-is to the resource server. 180 authorization server 181 An HTTP server capable of issuing tokens after successfully 182 authenticating the resource owner and obtaining authorization. 183 The authorization server may be the same server as the resource 184 server, or a separate entity. 186 end-user endpoint 187 The authorization server's HTTP endpoint capable of 188 authenticating the end-user and obtaining authorization. 190 token endpoint 191 The authorization server's HTTP endpoint capable of issuing 192 tokens and refreshing expired tokens. 194 client identifier 195 An unique identifier issued to the client to identify itself to 196 the authorization server. Client identifiers may have a 197 matching secret. 199 refresh token 200 A unique identifier used by the client to replace an expired 201 access token with a new access token without having to involve 202 the resource owner. A refresh token is used when the access 203 token is valid for a shorter time period than the duration of 204 the access grant approved by the resource owner. 206 2.2. Overview 208 Clients interact with a protected resource, first by requesting 209 access (which is granted in the form of an access token) from the 210 authorization server, and then by authenticating with the resource 211 server by presenting the access token. Figure 1 demonstrates the 212 flow between the client and authorization server (A, B), and the flow 213 between the client and resource server (C, D), when the client is 214 acting autonomously (the client is also the resource owner). 216 +--------+ +---------------+ 217 | |--(A)------ Credentials --------->| Authorization | 218 | | | Server | 219 | |<-(B)------ Access Token ---------| | 220 | | (w/ Optional Refresh Token) +---------------+ 221 | Client | 222 | | HTTP Request +---------------+ 223 | |--(C)--- with Access Token ------>| Resource | 224 | | | Server | 225 | |<-(D)------ HTTP Response --------| | 226 +--------+ +---------------+ 228 Figure 1 230 Access token strings can use any internal structure agreed upon 231 between the authorization server and the resource server, but their 232 structure is opaque to the client. Since the access token provides 233 the client access to the protected resource for the life of the 234 access token (or until revoked), the authorization server should 235 issue access tokens which expire within an appropriate time, usually 236 much shorter than the duration of the access grant. 238 When an access token expires, the client can request a new access 239 token from the authorization server by presenting its credentials 240 again (Figure 1), or by using the refresh token (if issued with the 241 access token) as shown in Figure 2. Once an expired access token has 242 been replaced with a new access token (A, B), the client uses the new 243 access token as before (C, D). 245 +--------+ +---------------+ 246 | |--(A)------ Refresh Token ------->| Authorization | 247 | | | Server | 248 | |<-(B)------ Access Token ---------| | 249 | | (with Optional Secret) +---------------+ 250 | Client | 251 | | HTTP Request +---------------+ 252 | |--(C)--- with Access Token ------>| Resource | 253 | | | Server | 254 | |<-(D)----- HTTP Response ---------| | 255 +--------+ +---------------+ 257 Figure 2 259 This specification defines a number of authorization flows to support 260 different client types and scenarios. These authorization flows can 261 be separated into three groups: user delegation flows, direct 262 credentials flows, and autonomous flows. 264 Additional authorization flows may be defined by other specifications 265 to cover different scenarios and client types. 267 User delegation flows are used to grant client access to protected 268 resources by the end-user without sharing the end-user credentials 269 (e.g. a username and password) with the client. Instead, the end- 270 user authenticates directly with the authorization server, and grants 271 client access to its protected resources. The user delegation flows 272 defined by this specifications are: 274 o User-Agent Flow - This flow is designed for clients running inside 275 a user-agent (typically a web browser). This flow is described in 276 Section 3.5. 278 o Web Server Flow - This flow is optimized for clients that are part 279 of a web server application, accessible via HTTP requests. This 280 flow is described in Section 3.6. 282 o Device Flow - This flow is suitable for clients executing on 283 limited devices, but where the end-user has separate access to a 284 user-agent on another computer or device. This flow is described 285 in Section 3.7. 287 Direct credentials flows enable clients to obtain an access token 288 with a single request using the client credentials or end-user 289 credentials without seeking additional resource owner authorization. 290 The direct credentials flows defined by this specification are: 292 o Username and Password Flow - This flow is used in cases where the 293 end-user trusts the client to handle its credentials but it is 294 still undesirable for the client to store the end-user's username 295 and password. This flow is only suitable when there is a high 296 degree of trust between the end-user and the client. This flow is 297 described in Section 3.8. 299 o Client Credentials Flow - The client uses its credentials to 300 obtain an access token. This flow is described in Section 3.9. 302 Autonomous flows enable clients to use utilize existing trust 303 relationships or different authorization constructs to obtain an 304 access token. They provide a bridge between OAuth and other trust 305 frameworks. The autonomous authorization flow defined by this 306 specifications is: 308 o Assertion Flow - The client presents an assertion such as a SAML 309 [OASIS.saml-core-2.0-os] assertion to the authorization server in 310 exchange for an access token. This flow is described in 311 Section 3.10. 313 2.3. Example 315 [[ Todo ]] 317 2.4. Notational Conventions 319 The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL NOT', 320 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'MAY', and 'OPTIONAL' in this 321 document are to be interpreted as described in [RFC2119]. 323 This document uses the Augmented Backus-Naur Form (ABNF) notation of 324 [I-D.ietf-httpbis-p1-messaging]. Additionally, the realm and auth- 325 param rules are included from [RFC2617], and the URI-Reference rule 326 from [RFC3986]. 328 2.5. Conformance 330 An implementation is not compliant if it fails to satisfy one or more 331 of the MUST or REQUIRED level requirements for the flows it 332 implements. An implementation that satisfies all the MUST or 333 REQUIRED level and all the SHOULD level requirements for its flows is 334 said to be "unconditionally compliant"; one that satisfies all the 335 MUST level requirements but not all the SHOULD level requirements for 336 its flows is said to be "conditionally compliant." 338 3. Obtaining an Access Token 340 The client obtains an access token by using one of the authorization 341 flows supported by the authorization server. The authorization flows 342 all use the same authorization and token endpoints, each with a 343 different set of request parameters and values. 345 Access tokens have a scope, duration, and other access attributes 346 granted by the resource owner. These attributes MUST be enforced by 347 the resource server when receiving a protected resource request, and 348 by the authorization server when receiving a token refresh request. 350 In many cases it is desirable to issue access tokens with a shorter 351 lifetime than the duration of the authorization grant. However, it 352 may be undesirable to require the resource owner to authorize the 353 request again. Instead, the authorization server issues a refresh 354 token in addition to the access token. When the access token 355 expires, the client can request a new access token without involving 356 the resource owner as long as the authorization grant is still valid. 357 The token refresh method is described in Section 4. 359 3.1. Client Credentials 361 When requesting access from the authorization server, the client 362 identifies itself using a set of client credentials. The client 363 credentials include a client identifier and an OPTIONAL symmetric 364 shared secret. The means through which the client obtains these 365 credentials are beyond the scope of this specification, but usually 366 involve registration with the authorization server. 368 The client identifier is used by the authorization server to 369 establish the identity of the client for the purpose of presenting 370 information to the resource owner prior to granting access, as well 371 as for providing different service levels to different clients. They 372 can also be used to block unauthorized clients from requesting 373 access. 375 Due to the nature of some clients, authorization servers SHOULD NOT 376 make assumptions about the confidentiality of client credentials 377 without establishing trust with the client operator. Authorization 378 servers SHOULD NOT issue client secrets to clients incapable of 379 keeping their secrets confidential. 381 3.2. End-User Endpoint 383 In flows that involved an end-user, clients direct the end-user to 384 the end-user endpoint to approve their access request. When 385 accessing the end-user endpoint, the end-user first authenticates 386 with the authorization server, and then approves or denies the access 387 request. 389 The way in which the authorization server authenticates the end-user 390 (e.g. username and password login, OpenID, session cookies) and in 391 which the authorization server obtains the end-user's authorization, 392 including whether it uses a secure channel such as TLS/SSL, is beyond 393 the scope of this specification. However, the authorization server 394 MUST first verify the identity of the end-user. 396 The URI of the end-user endpoint can be found in the service 397 documentation, or can be obtained by the client by making an 398 unauthorized protected resource request (from the "WWW-Authenticate" 399 response header "user-uri" attribute as described by Section 5.1). 401 The end-user endpoint advertised by the resource server MAY include a 402 query component as defined by [RFC3986] section 3, which must be 403 retained when adding additional query parameters. 405 Since requests to the end-user endpoint result in user authentication 406 and the transmission of sensitive values, the authorization server 407 SHOULD require the use of a transport-layer mechanism such as TLS/SSL 408 (or a secure channel with equivalent protections) when sending 409 requests to the end-user endpoint. 411 3.3. Token Endpoint 413 After obtaining authorization from the resource owner, clients 414 request an access token from the authorization server's token 415 endpoint. 417 The URI of the token endpoint can be found in the service 418 documentation, or can be obtained by the client by making an 419 unauthorized protected resource request (from the "WWW-Authenticate" 420 response header "token-uri" attribute as described by Section 5.1). 422 The token endpoint advertised by the resource server MAY include a 423 query component as defined by [RFC3986] section 3. 425 Since requests to the token endpoint result in the transmission of 426 plain text credentials in the HTTP request and response, the 427 authorization server MUST require the use of a transport-layer 428 mechanism such as TLS/SSL (or a secure channel with equivalent 429 protections) when sending requests to the token endpoints. 431 3.3.1. Client Authentication 433 The token endpoint requires the client to authenticate itself to the 434 authorization server. This is done by including the client 435 identifier (and optional secret) in the request. The client 436 identifier and secret are included in the request using two request 437 parameters: "client_id" and "client_secret". 439 For example (line breaks are for display purposes only): 441 POST /token HTTP/1.1 442 Host: server.example.com 443 Content-Type: application/x-www-form-urlencoded 445 type=web_server&client_id=s6BhdRkqt3& 446 client_secret=gX1fBat3bV&code=i1WsRn1uB1& 447 redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb 449 The client MAY include the client credentials using an HTTP 450 authentication scheme instead of using the "client_id" and 451 "client_secret" request parameters. Including the client credentials 452 using an HTTP authentication scheme fullfills the requirements of 453 including the parameters as defined by the various flows. The client 454 MUST NOT include the client credentials using more than one 455 mechanism. 457 The authorization server MUST accept the client credentials using 458 both the request parameters, and the HTTP Basic authentication scheme 459 as defined in [RFC2617]. The authorization server MAY support 460 additional HTTP authentication schemes. 462 For example (line breaks are for display purposes only): 464 POST /token HTTP/1.1 465 Host: server.example.com 466 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW 467 Content-Type: application/x-www-form-urlencoded 469 type=web_server&code=i1WsRn1uB1& 470 redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb 472 3.3.2. Response Format 474 Authorization servers respond to client requests by including a set 475 of response parameters in the entity body of the HTTP response. The 476 response uses one of three formats based on the format requested by 477 the client (using the "format" request parameter): 479 o The "application/json" media type as defined by [RFC4627]. The 480 parameters are serialized into a JSON structure by adding each 481 parameter at the highest structure level. Parameter names and 482 string values are included as JSON strings. Numerical values are 483 included as JSON numbers. 485 For example: 487 { 488 "access_token":"SlAV32hkKG", 489 "expires_in":3600, 490 "refresh_token":"8xLOxBtZp8" 491 } 493 o The "application/xml" media type as defined by [RFC3023]. The 494 parameters are serialized into an XML structure by adding each 495 parameter as a child element of the root "" element. [[ Add 496 namespace ]] 498 For example: 500 501 502 SlAV32hkKG 503 3600 504 8xLOxBtZp8 505 507 o The "application/x-www-form-urlencoded" media type as defined by 508 [W3C.REC-html40-19980424]. 510 For example (line breaks are for display purposes only): 512 access_token=SlAV32hkKG&expires_in=3600& 513 refresh_token=8xLOxBtZp8 515 The authorization server MUST include the HTTP "Cache-Control" 516 response header field with a value of "no-store" in any response 517 containing tokens, secrets, or other sensitive information. 519 3.3.2.1. Access Token Response 521 After receiving and verifying a valid and authorized access token 522 request from the client (as described in each of the flows below), 523 the authorization server constructs the response using the format 524 requested by the client, which includes the common parameters set as 525 well as additional flow-specific parameters. The formatted 526 parameters are sent to the client in the entity body of the HTTP 527 response with a 200 status code (OK). 529 The token response contains the following common parameters: 531 access_token 532 REQUIRED. The access token issued by the authorization server. 534 expires_in 535 OPTIONAL. The duration in seconds of the access token 536 lifetime. 538 refresh_token 539 OPTIONAL. The refresh token used to obtain new access tokens 540 using the same end-user access grant as described in Section 4. 542 access_token_secret 543 REQUIRED if requested by the client. The corresponding access 544 token secret as requested by the client. 546 scope 547 OPTIONAL. The scope of the access token as a list of space- 548 delimited strings. The value of the "scope" parameter is 549 defined by the authorization server. If the value contains 550 multiple space-delimited strings, their order does not matter, 551 and each string adds an additional access range to the 552 requested scope. 554 For example: 556 HTTP/1.1 200 OK 557 Content-Type: application/json 558 Cache-Control: no-store 560 { 561 "access_token":"SlAV32hkKG", 562 "expires_in":3600, 563 "refresh_token":"8xLOxBtZp8" 564 } 566 3.3.2.2. Error Response 568 If the token request is invalid or unauthorized, the authorization 569 server constructs a JSON-formatted response which includes the common 570 parameters set as well as additional flow-specific parameters. The 571 formatted parameters are sent to the client in the entity body of the 572 HTTP response with a 400 status code (Bad Request). 574 The response contains the following common parameter: 576 error 577 REQUIRED. The parameter value MUST be set to one of the values 578 specified by each flow. 580 For example: 582 HTTP/1.1 400 Bad Request 583 Content-Type: application/json 584 Cache-Control: no-store 586 { 587 "error":"incorrect_client_credentials" 588 } 590 3.4. Flow Parameters 592 The sizes of tokens and other values received from the authorization 593 server, are left undefined by this specification. Clients should 594 avoid making assumptions about value sizes. Servers should document 595 the expected size of any value they issue. 597 Unless otherwise noted, all the protocol parameter names and values 598 are case sensitive. 600 3.5. User-Agent Flow 602 The user-agent flow is a user delegation flow suitable for client 603 applications residing in a user-agent, typically implemented in a 604 browser using a scripting language such as JavaScript. These clients 605 cannot keep client secrets confidential and the authentication of the 606 client is based on the user-agent's same-origin policy. 608 Unlike other flows in which the client makes separate authorization 609 and access token requests, the client received the access token as a 610 result of the authorization request in the form of an HTTP 611 redirection. The client requests the authorization server to 612 redirect the user-agent to another web server or local resource 613 accessible to the browser which is capable of extracting the access 614 token from the response and passing it to the client. 616 This user-agent flow does not utilize the client secret since the 617 client executables reside on the end-user's computer or device which 618 makes the client secret accessible and exploitable. Because the 619 access token is encoded into the redirection URI, it may be exposed 620 to the end-user and other applications residing on the computer or 621 device. 623 +----------+ Client Identifier +----------------+ 624 | |>---(A)-- & Redirection URI --->| | 625 | | | | 626 End <--+ - - - +----(B)-- User authenticates -->| Authorization | 627 User | | | Server | 628 | |<---(C)-- Redirect URI --------<| | 629 | Client | with Access Token | | 630 | in | (w/ Optional Refresh Token) +----------------+ 631 | Browser | in Fragment 632 | | +----------------+ 633 | |>---(D)-- Redirect URI -------->| | 634 | | without Fragment | Web Server | 635 | | | with Client | 636 | (F) |<---(E)-- Web Page with -------<| Resource | 637 | Access | Script | | 638 | Token | +----------------+ 639 +----------+ 641 Figure 3 643 The user-agent flow illustrated in Figure 3 includes the following 644 steps: 646 (A) The client sends the user-agent to the authorization server and 647 includes its client identifier and redirection URI in the 648 request. 650 (B) The authorization server authenticates the end-user (via the 651 user-agent) and establishes whether the end-user grants or 652 denies the client's access request. 654 (C) Assuming the end-user granted access, the authorization server 655 redirects the user-agent to the redirection URI provided 656 earlier. The redirection URI includes the access token in the 657 URI fragment. 659 (D) The user-agent follows the redirection instructions by making a 660 request to the web server which does not include the fragment. 661 The user-agent retains the fragment information locally. 663 (E) The web server returns a web page containing a script capable of 664 extracting the access token from the URI fragment retained by 665 the user-agent. 667 (F) The user-agent executes the script provided by the web server 668 which extracts the access token and passes it to the client. 670 3.5.1. Client Requests Authorization 672 In order for the end-user to grant the client access, the client 673 sends the end-user to the authorization server. The client 674 constructs the request URI by adding the following URI query 675 parameters to the end-user endpoint URI: 677 type 678 REQUIRED. The parameter value MUST be set to "user_agent". 680 client_id 681 REQUIRED. The client identifier as described in Section 3.1. 683 redirect_uri 684 REQUIRED unless a redirection URI has been established between 685 the client and authorization server via other means. An 686 absolute URI to which the authorization server will redirect 687 the user-agent to when the end-user authorization step is 688 completed. The authorization server SHOULD require the client 689 to pre-register their redirection URI. Authorization servers 690 MAY restrict the redirection URI to not include a query 691 component as defined by [RFC3986] section 3. 693 state 694 OPTIONAL. An opaque value used by the client to maintain state 695 between the request and callback. The authorization server 696 includes this value when redirecting the user-agent back to the 697 client. 699 scope 700 OPTIONAL. The scope of the access request expressed as a list 701 of space-delimited strings. The value of the "scope" parameter 702 is defined by the authorization server. If the value contains 703 multiple space-delimited strings, their order does not matter, 704 and each string adds an additional access range to the 705 requested scope. 707 immediate 708 OPTIONAL. The parameter value must be set to "true" or 709 "false". If set to "true", the authorization server MUST NOT 710 prompt the end-user to authenticate or approve access. 711 Instead, the authorization server attempts to establish the 712 end-user's identity via other means (e.g. browser cookies) and 713 checks if the end-user has previously approved an identical 714 access request by the same client and if that access grant is 715 still active. If the authorization server does not support an 716 immediate check or if it is unable to establish the end-user's 717 identity or approval status, it MUST deny the request without 718 prompting the end-user. Defaults to "false" if omitted. 720 secret_type 721 OPTIONAL. The access token secret type as described by 722 Section 5.3. If omitted, the authorization server will issue a 723 bearer token (an access token without a matching secret) as 724 described by Section 5.2. 726 The client directs the end-user to the constructed URI using an HTTP 727 redirection response, or by other means available to it via the end- 728 user's user-agent. The request MUST use the HTTP "GET" method. 730 For example, the client directs the end-user's user-agent to make the 731 following HTTPS request (line breaks are for display purposes only): 733 GET /authorize?type=user_agent&client_id=s6BhdRkqt3& 734 redirect_uri=https%3A%2F%2FEexample%2Ecom%2Frd HTTP/1.1 735 Host: server.example.com 737 If the client has previously registered a redirection URI with the 738 authorization server, the authorization server MUST verify that the 739 redirection URI received matches the registered URI associated with 740 the client identifier. 742 The authorization server authenticates the end-user and obtains an 743 authorization decision (by asking the end-user or establishing 744 approval via other means). The authorization server sends the end- 745 user's user-agent to the provided client redirection URI using an 746 HTTP redirection response. 748 3.5.1.1. End-user Grants Authorization 750 If the end-user authorizes the access request, the authorization 751 server issues an access token and delivers it to the client by adding 752 the following parameters, using the 753 "application/x-www-form-urlencoded" format as defined by 754 [W3C.REC-html40-19980424], to the redirection URI fragment: 756 access_token 757 REQUIRED. The access token. 759 expires_in 760 OPTIONAL. The duration in seconds of the access token 761 lifetime. 763 refresh_token 764 OPTIONAL. The refresh token. 766 state 767 REQUIRED if the "state" parameter was present in the client 768 authorization request. Set to the exact value received from 769 the client. 771 access_token_secret 772 REQUIRED if requested by the client. The corresponding access 773 token secret as requested by the client. 775 For example, the authorization server redirects the end-user's user- 776 agent by sending the following HTTP response: 778 HTTP/1.1 302 Found 779 Location: http://example.com/rd#access_token=FJQbwq9&expires_in=3600 781 3.5.1.2. End-user Denies Authorization 783 If the end-user denied the access request, the authorization server 784 responds to the client by adding the following parameters, using the 785 "application/x-www-form-urlencoded" format as defined by 786 [W3C.REC-html40-19980424], to the redirection URI fragment: 788 error 789 REQUIRED. The parameter value MUST be set to "user_denied". 791 state 792 REQUIRED if the "state" parameter was present in the client 793 authorization request. Set to the exact value received from 794 the client. 796 For example, the authorization server responds with the following: 798 HTTP/1.1 302 Found 799 Location: http://example.com/rd#error=user_denied 801 The authorization flow concludes unsuccessfully. To extract the 802 error message, the client follows the steps described in 803 Section 3.5.2. 805 3.5.2. Client Extracts Access Token 807 The user-agent follows the authorization server redirection response 808 by making an HTTP "GET" request to the URI received in the "Location" 809 HTTP response header. The user-agent SHALL NOT include the fragment 810 component with the request. 812 For example, the user-agent makes the following HTTP "GET" request in 813 response to the redirection directive received from the authorization 814 server: 816 GET /rd HTTP/1.1 817 Host: example.com 819 The HTTP response to the redirection request returns a web page 820 (typically an HTML page with an embedded script) capable of accessing 821 the full redirection URI including the fragment retained by the user- 822 agent, and extracting the access token (and other parameters) 823 contained in the fragment. 825 3.6. Web Server Flow 827 The web server flow is a user delegation flow suitable for clients 828 capable of interacting with the end-user's user-agent (typically a 829 web browser) and capable of receiving incoming requests from the 830 authorization server (capable of acting as an HTTP server). 832 +----------+ Client Identifier +---------------+ 833 | -+----(A)-- & Redirect URI ------->| | 834 | End-user | | Authorization | 835 | at |<---(B)-- User authenticates --->| Server | 836 | Browser | | | 837 | -+----(C)-- Verification Code ----<| | 838 +-|----|---+ +---------------+ 839 | | ^ v 840 (A) (C) | | 841 | | | | 842 ^ v | | 843 +---------+ | | 844 | |>---(D)-- Client Credentials, --------' | 845 | Web | Verification Code, | 846 | Client | & Redirect URI | 847 | | | 848 | |<---(E)------- Access Token -----------------' 849 +---------+ (w/ Optional Refresh Token) 851 Figure 4 853 The web server flow illustrated in Figure 4 includes the following 854 steps: 856 (A) The web client initiates the flow by redirecting the end-user's 857 user-agent to the end-user endpoint with its client identifier 858 and a redirect URI to which the authorization server will send 859 the end-user back once authorization is received (or denied). 861 (B) The authorization server authenticates the end-user (via the 862 user-agent) and establishes whether the end-user grants or 863 denies the client's access request. 865 (C) Assuming the end-user granted access, the authorization server 866 redirects the user-agent back to the client to the redirection 867 URI provided earlier. The authorization includes a verification 868 code for the client to use to obtain an access token. 870 (D) The client requests an access token from the authorization 871 server by including its client credentials (identifier and 872 secret), as well as the verification code received in the 873 previous step. 875 (E) The authorization server validates the client credentials and 876 the verification code and responds back with the access token. 878 3.6.1. Client Requests Authorization 880 In order for the end-user to grant the client access, the client 881 sends the end-user to the authorization server. The client 882 constructs the request URI by adding the following URI query 883 parameters to the end-user endpoint URI: 885 type 886 REQUIRED. The parameter value MUST be set to "web_server". 888 client_id 889 REQUIRED. The client identifier as described in Section 3.1. 891 redirect_uri 892 REQUIRED unless a redirection URI has been established between 893 the client and authorization server via other means. An 894 absolute URI to which the authorization server will redirect 895 the user-agent to when the end-user authorization step is 896 completed. The authorization server MAY require the client to 897 pre-register their redirection URI. Authorization servers MAY 898 restrict the redirection URI to not include a query component 899 as defined by [RFC3986] section 3. 901 state 902 OPTIONAL. An opaque value used by the client to maintain state 903 between the request and callback. The authorization server 904 includes this value when redirecting the user-agent back to the 905 client. 907 scope 908 OPTIONAL. The scope of the access request expressed as a list 909 of space-delimited strings. The value of the "scope" parameter 910 is defined by the authorization server. If the value contains 911 multiple space-delimited strings, their order does not matter, 912 and each string adds an additional access range to the 913 requested scope. 915 immediate 916 OPTIONAL. The parameter value must be set to "true" or 917 "false". If set to "true", the authorization server MUST NOT 918 prompt the end-user to authenticate or approve access. 919 Instead, the authorization server attempts to establish the 920 end-user's identity via other means (e.g. browser cookies) and 921 checks if the end-user has previously approved an identical 922 access request by the same client and if that access grant is 923 still active. If the authorization server does not support an 924 immediate check or if it is unable to establish the end-user's 925 identity or approval status, it MUST deny the request without 926 prompting the end-user. Defaults to "false" if omitted. 928 The client directs the end-user to the constructed URI using an HTTP 929 redirection response, or by other means available to it via the end- 930 user's user-agent. The request MUST use the HTTP "GET" method. 932 For example, the client directs the end-user's user-agent to make the 933 following HTTPS requests (line breaks are for display purposes only): 935 GET /authorize?type=web_server&client_id=s6BhdRkqt3&redirect_uri= 936 https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb HTTP/1.1 937 Host: server.example.com 939 If the client has previously registered a redirection URI with the 940 authorization server, the authorization server MUST verify that the 941 redirection URI received matches the registered URI associated with 942 the client identifier. 944 The authorization server authenticates the end-user and obtains an 945 authorization decision (by asking the end-user or establishing 946 approval via other means). The authorization server sends the end- 947 user's user-agent to the provided client redirection URI using an 948 HTTP redirection response, or by other means available to it via the 949 end-user's user-agent. 951 3.6.1.1. End-user Grants Authorization 953 If the end-user authorizes the access request, the authorization 954 server generates a verification code and associates it with the 955 client identifier and redirection URI. The authorization server 956 constructs the request URI by adding the following parameters to the 957 query component of redirection URI provided by the client: 959 code 960 REQUIRED. The verification code generated by the authorization 961 server. 963 state 964 REQUIRED if the "state" parameter was present in the client 965 authorization request. Set to the exact value received from 966 the client. 968 The verification code should expire shortly after it is issued and 969 allowed for a single use. 971 For example, the authorization server redirects the end-user's user- 972 agent by sending the following HTTP response: 974 HTTP/1.1 302 Found 975 Location: https://client.example.com/cb?code=i1WsRn1uB1 977 In turn, the end-user's user-agent makes the following HTTPS "GET" 978 request: 980 GET /cb?code=i1WsRn1uB1 HTTP/1.1 981 Host: client.example.com 983 3.6.1.2. End-user Denies Authorization 985 If the end-user denied the access request, the authorization server 986 constructs the request URI by adding the following parameters to the 987 query component of the redirection URI provided by the client: 989 error 990 REQUIRED. The parameter value MUST be set to "user_denied". 992 state 993 REQUIRED if the "state" parameter was present in the client 994 authorization request. Set to the exact value received from 995 the client. 997 For example, the authorization server directs the client to make the 998 following HTTP request: 1000 GET /cb?error=user_denied HTTP/1.1 1001 Host: client.example.com 1003 The authorization flow concludes unsuccessfully. 1005 3.6.2. Client Requests Access Token 1007 The client obtains an access token from the authorization server by 1008 making an HTTP "POST" request to the token endpoint. The client 1009 constructs a request URI by adding the following parameters to the 1010 request: 1012 type 1013 REQUIRED. The parameter value MUST be set to "web_server". 1015 client_id 1016 REQUIRED. The client identifier as described in Section 3.1. 1018 client_secret 1019 REQUIRED if the client identifier has a matching secret. The 1020 client secret as described in Section 3.1. 1022 code 1023 REQUIRED. The verification code received from the 1024 authorization server. 1026 redirect_uri 1027 REQUIRED. The redirection URI used in the initial request. 1029 secret_type 1030 OPTIONAL. The access token secret type as described by 1031 Section 5.3. If omitted, the authorization server will issue a 1032 bearer token (an access token without a matching secret) as 1033 described by Section 5.2. 1035 format 1036 OPTIONAL. The response format requested by the client. Value 1037 MUST be one of "json", "xml", or "form". Defaults to "json" if 1038 no omitted. 1040 For example, the client makes the following HTTPS request (line 1041 breaks are for display purposes only): 1043 POST /token HTTP/1.1 1044 Host: server.example.com 1045 Content-Type: application/x-www-form-urlencoded 1047 type=web_server&client_id=s6BhdRkqt3& 1048 client_secret=gX1fBat3bV&code=i1WsRn1uB1& 1049 redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb 1051 The authorization server MUST verify that the verification code, 1052 client identity, client secret, and redirection URI are all valid and 1053 match its stored association. If the request is valid, the 1054 authorization server issues a successful response as described in 1055 Section 3.3.2.1. 1057 For example: 1059 HTTP/1.1 200 OK 1060 Content-Type: application/json 1061 Cache-Control: no-store 1063 { 1064 "access_token":"SlAV32hkKG", 1065 "expires_in":3600, 1066 "refresh_token":"8xLOxBtZp8" 1067 } 1069 If the request is invalid, the authorization server returns an error 1070 response as described in Section 3.3.2.2 with one of the following 1071 error codes: 1073 o "redirect_uri_mismatch" 1075 o "bad_verification_code" 1077 o "incorrect_client_credentials" 1079 For example: 1081 HTTP/1.1 400 Bad Request 1082 Content-Type: application/json 1083 Cache-Control: no-store 1085 { 1086 "error":"incorrect_client_credentials" 1087 } 1089 3.7. Device Flow 1091 The device flow is a user delegation flow suitable for clients 1092 executing on devices which do not have an easy data-entry method 1093 (e.g. game consoles or media hub), but where the end-user has 1094 separate access to a user-agent on another computer or device (e.g. 1096 home computer, a laptop, or a smart phone). The client is incapable 1097 of receiving incoming requests from the authorization server 1098 (incapable of acting as an HTTP server). 1100 Instead of interacting with the end-user's user-agent, the client 1101 instructs the end-user to use another computer or device and connect 1102 to the authorization server to approve the access request. Since the 1103 client cannot receive incoming requests, it polls the authorization 1104 server repeatedly until the end-user completes the approval process. 1106 This device flow does not utilize the client secret since the client 1107 executables reside on a local device which makes the client secret 1108 accessible and exploitable. 1110 +----------+ +----------------+ 1111 | |>---(A)-- Client Identifier --->| | 1112 | | | | 1113 | |<---(B)-- Verification Code, --<| | 1114 | | User Code, | | 1115 | | & Verification URI | | 1116 | Device | | | 1117 | Client | Client Identifier & | | 1118 | |>---(E)-- Verification Code --->| | 1119 | | ... | | 1120 | |>---(E)---> | | 1121 | | | Authorization | 1122 | |<---(F)-- Access Token --------<| Server | 1123 +----------+ (w/ Optional Refresh Token) | | 1124 v | | 1125 : | | 1126 (C) User Code & Verification URI | | 1127 : | | 1128 v | | 1129 +----------+ | | 1130 | End-user | | | 1131 | at |<---(D)-- User authenticates -->| | 1132 | Browser | | | 1133 +----------+ +----------------+ 1135 Figure 5 1137 The device flow illustrated in Figure 5 includes the following steps: 1139 (A) The client requests access from the authorization server and 1140 includes its client identifier in the request. 1142 (B) The authorization server issues a verification code, an end-user 1143 code, and provides the end-user verification URI. 1145 (C) The client instructs the end-user to use its user-agent 1146 (elsewhere) and visit the provided end-user verification URI. 1147 The client provides the end-user with the end-user code to enter 1148 in order to grant access. 1150 (D) The authorization server authenticates the end-user (via the 1151 user-agent) and prompts the end-user to grant the client's 1152 access request. If the end-user agrees to the client's access 1153 request, the end-user enters the end-user code provided by the 1154 client. The authorization server validates the end-user code 1155 provided by the end-user. 1157 (E) While the end-user authorizes (or denies) the client's request 1158 (D), the client repeatedly polls the authorization server to 1159 find out if the end-user completed the end-user authorization 1160 step. The client includes the verification code and its client 1161 identifier. 1163 (F) Assuming the end-user granted access, the authorization server 1164 validates the verification code provided by the client and 1165 responds back with the access token. 1167 3.7.1. Client Requests Authorization 1169 The client initiates the flow by requesting a set of verification 1170 codes from the authorization server by making an HTTP "POST" request 1171 to the token endpoint. The client constructs a request URI by adding 1172 the following parameters to the request: 1174 type 1175 REQUIRED. The parameter value MUST be set to "device_code". 1177 client_id 1178 REQUIRED. The client identifier as described in Section 3.1. 1180 scope 1181 OPTIONAL. The scope of the access request expressed as a list 1182 of space-delimited strings. The value of the "scope" parameter 1183 is defined by the authorization server. If the value contains 1184 multiple space-delimited strings, their order does not matter, 1185 and each string adds an additional access range to the 1186 requested scope. 1188 format 1189 OPTIONAL. The response format requested by the client. Value 1190 MUST be one of "json", "xml", or "form". Defaults to "json" if 1191 no omitted. 1193 For example, the client makes the following HTTPS request (line 1194 breaks are for display purposes only): 1196 POST /token?type=device_code&client_id=s6BhdRkqt3 1197 HTTP/1.1 1198 Host: server.example.com 1200 In response, the authorization server generates a verification code 1201 and an end-user code and includes them in the HTTP response body 1202 using the "application/json" format as described by Section 3.3.2 1203 with a 200 status code (OK). The response contains the following 1204 parameters: 1206 code 1207 REQUIRED. The verification code. 1209 user_code 1210 REQUIRED. The end-user code. 1212 verification_uri 1213 REQUIRED. The end-user verification URI on the authorization 1214 server. The URI should be short and easy to remember as end- 1215 users will be asked to manually type it into their user-agent. 1217 expires_in 1218 OPTIONAL. The duration in seconds of the verification code 1219 lifetime. 1221 interval 1222 OPTIONAL. The minimum amount of time in seconds that the 1223 client SHOULD wait between polling requests to the token 1224 endpoint. 1226 For example: 1228 HTTP/1.1 200 OK 1229 Content-Type: application/json 1230 Cache-Control: no-store 1232 { 1233 "code":"74tq5miHKB", 1234 "user_code":"94248", 1235 "verification_uri":"http://www.example.com/device", 1236 "interval"=5 1237 } 1239 The client displays the end-user code and the end-user verification 1240 URI to the end-user, and instructs the end-user to visit the URI 1241 using a user-agent and enter the end-user code. 1243 The end-user manually types the provided verification URI and 1244 authenticates with the authorization server. The authorization 1245 server prompts the end-user to authorize the client's request by 1246 entering the end-user code provided by the client. Once the end-user 1247 approves or denies the request, the authorization server informs the 1248 end-user to return to the device for further instructions. 1250 3.7.2. Client Requests Access Token 1252 Since the client is unable to receive incoming requests from the 1253 authorization server, it polls the authorization server repeatedly 1254 until the end-user grants or denies the request, or the verification 1255 code expires. 1257 The client makes the following request at an arbitrary but reasonable 1258 interval which MUST NOT exceed the minimum interval rate provided by 1259 the authorization server (if present via the "interval" parameter). 1260 Alternatively, the client MAY provide a user interface for the end- 1261 user to manually inform it when authorization was granted. 1263 The client requests an access token by making an HTTP "POST" request 1264 to the token endpoint. The client constructs a request URI by adding 1265 the following parameters to the request: 1267 type 1268 REQUIRED. The parameter value MUST be set to "device_token". 1270 client_id 1271 REQUIRED. The client identifier as described in Section 3.1. 1273 code 1274 The verification code received from the authorization server. 1276 secret_type 1277 OPTIONAL. The access token secret type as described by 1278 Section 5.3. If omitted, the authorization server will issue a 1279 bearer token (an access token without a matching secret) as 1280 described by Section 5.2. 1282 format 1283 OPTIONAL. The response format requested by the client. Value 1284 MUST be one of "json", "xml", or "form". Defaults to "json" if 1285 no omitted. 1287 For example, the client makes the following HTTPS request (line 1288 breaks are for display purposes only): 1290 POST /token?type=device_token&client_id=s6BhdRkqt3 1291 &code=74tq5miHKB HTTP/1.1 1292 Host: server.example.com 1294 If the end-user authorized the request, the authorization server 1295 issues an access token response as described in Section 3.3.2.1. 1297 For example: 1299 HTTP/1.1 200 OK 1300 Content-Type: application/json 1301 Cache-Control: no-store 1303 { 1304 "access_token":"SlAV32hkKG", 1305 "expires_in":3600, 1306 "refresh_token":"8xLOxBtZp8" 1307 } 1309 If the request is invalid, the authorization server returns an error 1310 response as described in Section 3.3.2.2 with one of the following 1311 error codes: 1313 o "authorization_declined" 1315 o "bad_verification_code" 1317 For example: 1319 HTTP/1.1 400 Bad Request 1320 Content-Type: application/json 1321 Cache-Control: no-store 1323 { 1324 "error":"authorization_declined" 1325 } 1327 If the end-user authorization is pending or expired without receiving 1328 any response from the end-user, or the client is exceeding the 1329 allowed polling interval, the authorization server returns an error 1330 response as described in Section 3.3.2.2 with one of the following 1331 error codes: 1333 o "'authorization_pending" 1335 o "slow_down" 1337 o "code_expired" 1339 For example: 1341 HTTP/1.1 400 Bad Request 1342 Content-Type: application/json 1343 Cache-Control: no-store 1345 { 1346 "error":"authorization_pending" 1347 } 1349 3.8. Username and Password Flow 1351 The username and password flow is suitable for clients capable of 1352 asking end-users for their usernames and passwords. It is also used 1353 to migrate existing clients using direct authentication schemes such 1354 as HTTP Basic or Digest authentication to OAuth by converting the 1355 end-user credentials stored with tokens. 1357 However, unlike the HTTP Basic authentication scheme defined in 1358 [RFC2617], the end-user's credentials are used in a single request 1359 and are exchanged for an access token and refresh token which 1360 eliminates the client need to store them for future use. 1362 The methods through which the client prompts end users for their 1363 usernames and passwords is beyond the scope of this specification. 1364 The client MUST discard the usernames and passwords once an access 1365 token has been obtained. 1367 This flow is suitable in cases where the end-user already has a trust 1368 relationship with the client, such as its computer operating system 1369 or highly privileged applications. Authorization servers should take 1370 special care when enabling the username and password flow, and only 1371 when other delegation flows are not viable. 1373 End-user 1374 v 1375 : 1376 (A) 1377 : 1378 v 1379 +--------+ +---------------+ 1380 | | Client Credentials | | 1381 | |>--(B)--- & User Credentials ---->| Authorization | 1382 | Client | | Server | 1383 | |<--(C)---- Access Token ---------<| | 1384 | | (w/ Optional Refresh Token) | | 1385 +--------+ +---------------+ 1387 Figure 6 1389 The username and password flow illustrated in Figure 6 includes the 1390 following steps: 1392 (A) The end-user provides the client with its username and password. 1394 (B) The client sends an access token request to the authorization 1395 server and includes its client identifier and client secret, and 1396 the end-user's username and password. 1398 (C) The authorization server validates the end-user credentials and 1399 the client credentials and issues an access token. 1401 3.8.1. Client Requests Access Token 1403 The client requests an access token by making an HTTP "POST" request 1404 to the token endpoint. The client constructs a request URI by adding 1405 the following parameters to the request: 1407 type 1408 REQUIRED. The parameter value MUST be set to "username". 1410 client_id 1411 REQUIRED. The client identifier as described in Section 3.1. 1413 client_secret 1414 REQUIRED. The client secret as described in Section 3.1. 1415 OPTIONAL if no client secret was issued. 1417 username 1418 REQUIRED. The end-user's username. 1420 password 1421 REQUIRED. The end-user's password. 1423 scope 1424 OPTIONAL. The scope of the access request expressed as a list 1425 of space-delimited strings. The value of the "scope" parameter 1426 is defined by the authorization server. If the value contains 1427 multiple space-delimited strings, their order does not matter, 1428 and each string adds an additional access range to the 1429 requested scope. 1431 secret_type 1432 OPTIONAL. The access token secret type as described by 1433 Section 5.3. If omitted, the authorization server will issue a 1434 bearer token (an access token without a matching secret) as 1435 described by Section 5.2. 1437 format 1438 OPTIONAL. The response format requested by the client. Value 1439 MUST be one of "json", "xml", or "form". Defaults to "json" if 1440 no omitted. 1442 For example, the client makes the following HTTPS request (line 1443 breaks are for display purposes only): 1445 POST /token HTTP/1.1 1446 Host: server.example.com 1448 type=username&client_id=s6BhdRkqt3&client_secret= 1449 47HDu8s&username=johndoe&password=A3ddj3w 1451 The authorization server MUST validate the client credentials and 1452 end-user credentials and if valid issues an access token response as 1453 described in Section 3.3.2.1. 1455 For example: 1457 HTTP/1.1 200 OK 1458 Content-Type: application/json 1459 Cache-Control: no-store 1461 { 1462 "access_token":"SlAV32hkKG", 1463 "expires_in":3600, 1464 "refresh_token":"8xLOxBtZp8" 1465 } 1467 If the request is invalid, the authorization server returns an error 1468 response as described in Section 3.3.2.2 with one of the following 1469 error codes: 1471 o "incorrect_client_credentials" 1473 o "unauthorized_client'" - The client is not permitted to use this 1474 flow. 1476 For example: 1478 HTTP/1.1 400 Bad Request 1479 Content-Type: application/json 1480 Cache-Control: no-store 1482 { 1483 "error":"incorrect_client_credentials" 1484 } 1486 3.9. Client Credentials Flow 1488 The client credentials flow is used when the client acts on behalf of 1489 itself (the client is the resource owner), or when the client 1490 credentials are used to obtain an access token representing a 1491 previously established access authorization. The client secret is 1492 assumed to be high-entropy since it is not designed to be memorized 1493 by an end-user. 1495 +--------+ +---------------+ 1496 | | | | 1497 | |>--(A)--- Client Credentials ---->| Authorization | 1498 | Client | | Server | 1499 | |<--(B)---- Access Token ---------<| | 1500 | | (w/ Optional Refresh Token) | | 1501 +--------+ +---------------+ 1503 Figure 7 1505 The client credential flow illustrated in Figure 7 includes the 1506 following steps: 1508 (A) The client sends an access token request to the authorization 1509 server and includes its client identifier and client secret. 1511 (B) The authorization server validates the client credentials and 1512 issues an access token. 1514 3.9.1. Client Requests Access Token 1516 The client requests an access token by making an HTTP "POST" request 1517 to the token endpoint. The client constructs a request URI by adding 1518 the following parameters to the request: 1520 type 1521 REQUIRED. The parameter value MUST be set to 1522 "client_credentials". 1524 client_id 1525 REQUIRED. The client identifier as described in Section 3.1. 1527 client_secret 1528 REQUIRED. The client secret as described in Section 3.1. 1530 scope 1531 OPTIONAL. The scope of the access request expressed as a list 1532 of space-delimited strings. The value of the "scope" parameter 1533 is defined by the authorization server. If the value contains 1534 multiple space-delimited strings, their order does not matter, 1535 and each string adds an additional access range to the 1536 requested scope. 1538 secret_type 1539 OPTIONAL. The access token secret type as described by 1540 Section 5.3. If omitted, the authorization server will issue a 1541 bearer token (an access token without a matching secret) as 1542 described by Section 5.2. 1544 format 1545 OPTIONAL. The response format requested by the client. Value 1546 MUST be one of "json", "xml", or "form". Defaults to "json" if 1547 no omitted. 1549 For example, the client makes the following HTTPS request: 1551 POST /token HTTP/1.1 1552 Host: server.example.com 1554 type=client_credentials&client_id=s6BhdRkqt3&client_secret=47HDu8s 1556 The authorization server MUST validate the client credentials and if 1557 valid issues an access token response as described in 1558 Section 3.3.2.1. 1560 For example: 1562 HTTP/1.1 200 OK 1563 Content-Type: application/json 1564 Cache-Control: no-store 1566 { 1567 "access_token":"SlAV32hkKG", 1568 "expires_in":3600, 1569 "refresh_token":"8xLOxBtZp8" 1570 } 1572 If the request is invalid, the authorization server returns an error 1573 response as described in Section 3.3.2.2 with one of the following 1574 error codes: 1576 o "incorrect_client_credentials" 1578 For example: 1580 HTTP/1.1 400 Bad Request 1581 Content-Type: application/json 1582 Cache-Control: no-store 1584 { 1585 "error":"incorrect_client_credentials" 1586 } 1588 3.10. Assertion Flow 1590 The assertion flow is used when a client wishes to exchange an 1591 existing security token or assertion for an access token. This flow 1592 is suitable when the client is the resource owner or is acting on 1593 behalf of the resource owner (based on the content of the assertion 1594 used). 1596 The assertion flow requires the client to obtain a assertion (such as 1597 a SAML [OASIS.saml-core-2.0-os] assertion) from an assertion issuer 1598 or to self-issue an assertion prior to initiating the flow. The 1599 assertion format, the process by which the assertion is obtained, and 1600 the method of validating the assertion are defined by the assertion 1601 issuer and the authorization server, and are beyond the scope of this 1602 specification. 1604 +--------+ +---------------+ 1605 | | | | 1606 | |>--(A)------ Assertion ---------->| Authorization | 1607 | Client | | Server | 1608 | |<--(B)---- Access Token ---------<| | 1609 | | | | 1610 +--------+ +---------------+ 1612 Figure 8 1614 The assertion flow illustrated in Figure 8 includes the following 1615 steps: 1617 (A) The client sends an access token request to the authorization 1618 server and includes an assertion. 1620 (B) The authorization server validates the assertion and issues an 1621 access token. 1623 3.10.1. Client Requests Access Token 1625 The client requests an access token by making an HTTP "POST" request 1626 to the token endpoint. The client constructs a request URI by adding 1627 the following parameters to the request: 1629 type 1630 REQUIRED. The parameter value MUST be set to "assertion". 1632 format 1633 REQUIRED. The format of the assertion as defined by the 1634 authorization server. The value MUST be an absolute URI. 1636 assertion 1637 REQUIRED. The assertion. 1639 client_id 1640 OPTIONAL. The client identifier as described in Section 3.1. 1641 The authorization server MAY require including the client 1642 credentials with the request based on the assertion properties. 1644 client_secret 1645 OPTIONAL. The client secret as described in Section 3.1. MUST 1646 NOT be included if the "client_id" parameter is omitted. 1648 scope 1649 OPTIONAL. The scope of the access request expressed as a list 1650 of space-delimited strings. The value of the "scope" parameter 1651 is defined by the authorization server. If the value contains 1652 multiple space-delimited strings, their order does not matter, 1653 and each string adds an additional access range to the 1654 requested scope. 1656 secret_type 1657 OPTIONAL. The access token secret type as described by 1658 Section 5.3. If omitted, the authorization server will issue a 1659 bearer token (an access token without a matching secret) as 1660 described by Section 5.2. 1662 format 1663 OPTIONAL. The response format requested by the client. Value 1664 MUST be one of "json", "xml", or "form". Defaults to "json" if 1665 no omitted. 1667 For example, the client makes the following HTTPS request (line 1668 breaks are for display purposes only): 1670 POST /token HTTP/1.1 1671 Host: server.example.com 1673 type=assertion&format=_______&assertion=_______ 1675 The authorization server MUST validate the assertion and if valid 1676 issues an access token response as described in Section 3.3.2.1. The 1677 authorization server SHOULD NOT issue a refresh token. 1679 For example: 1681 HTTP/1.1 200 OK 1682 Content-Type: application/json 1683 Cache-Control: no-store 1685 { 1686 "access_token":"SlAV32hkKG", 1687 "expires_in":3600 1688 } 1690 If the request is invalid, the authorization server returns an error 1691 response as described in Section 3.3.2.2 with one of the following 1692 error codes: 1694 o "invalid_assertion" 1696 o "unknown_format" 1697 For example: 1699 HTTP/1.1 400 Bad Request 1700 Content-Type: application/json 1701 Cache-Control: no-store 1703 { 1704 "error":"invalid_assertion" 1705 } 1707 Authorization servers SHOULD issue access tokens with a limited 1708 lifetime and require clients to refresh them by requesting a new 1709 access token using the same assertion if it is still valid. 1710 Otherwise the client MUST obtain a new valid assertion. 1712 4. Refreshing an Access Token 1714 Token refresh is used when the lifetime of an access token is shorter 1715 than the lifetime of the authorization grant. It allows clients to 1716 obtain a new access token without having to go through the 1717 authorization flow again or involve the resource owner. It is also 1718 used to obtain a new token with different security properties (e.g. 1719 bearer token, token with shared symmetric secret). 1721 +--------+ Client Credentials, +---------------+ 1722 | | Refresh Token, | | 1723 | |>--(A)----- & Secret Type ------->| Authorization | 1724 | Client | | Server | 1725 | |<--(B)----- Access Token --------<| | 1726 | | & Optional Secret | | 1727 +--------+ +---------------+ 1729 Figure 9 1731 To refresh a token, the client constructs an HTTP "POST" request to 1732 the token endpoint and includes the following parameters in the HTTP 1733 request body using the "application/x-www-form-urlencoded" content 1734 type as defined by [W3C.REC-html40-19980424]: 1736 type 1737 REQUIRED. The parameter value MUST be set to "refresh". 1739 client_id 1740 REQUIRED. The client identifier as described in Section 3.1. 1742 client_secret 1743 REQUIRED if the client was issued a secret. The client secret. 1745 refresh_token 1746 REQUIRED. The refresh token associated with the access token 1747 to be refreshed. 1749 secret_type 1750 OPTIONAL. The access token secret type as described by 1751 Section 5.3. If omitted, the authorization server will issue a 1752 bearer token (an access token without a matching secret) as 1753 described by Section 5.2. 1755 format 1756 OPTIONAL. The response format requested by the client. Value 1757 MUST be one of "json", "xml", or "form". Defaults to "json" if 1758 no omitted. 1760 For example, the client makes the following HTTPS request (line break 1761 are for display purposes only): 1763 POST /token HTTP/1.1 1764 Host: server.example.com 1765 Content-Type: application/x-www-form-urlencoded 1767 type=refresh_token&client_id=s6BhdRkqt3&client_secret=8eSEIpnqmM 1768 &refresh_token=n4E9O119d&secret_type=hmac-sha256 1770 verify the client credential, the validity of the refresh token, and 1771 that the resource owner's authorization is still valid. If the 1772 request is valid, the authorization server issues an access token 1773 response as described in Section 3.3.2.1. The authorization server 1774 MAY issue a new refresh token in which case the client MUST NOT use 1775 the previous refresh token and replace it with the newly issued 1776 refresh token. 1778 For example: 1780 HTTP/1.1 200 OK 1781 Content-Type: application/json 1782 Cache-Control: no-store 1784 { 1785 "access_token":"SlAV32hkKG", 1786 "expires_in":3600 1787 } 1789 If the request is invalid, the authorization server returns an error 1790 response as described in Section 3.3.2.2 with one of the following 1791 error codes: 1793 o "incorrect_client_credentials" 1795 o "authorization_expired" 1797 o "unsupported_secret_type" 1799 For example: 1801 HTTP/1.1 400 Bad Request 1802 Content-Type: application/json 1803 Cache-Control: no-store 1805 { 1806 "error":"incorrect_client_credentials" 1807 } 1809 5. Accessing a Protected Resource 1811 Clients access protected resources by presenting an access token to 1812 the resource server. The methods used by the resource server to 1813 validate the access token are beyond the scope of this specification, 1814 but generally involve an interaction or coordination between the 1815 resource server and authorization server. 1817 The method in which a client uses an access token depends on the 1818 security properties of the access tokens. By default, access tokens 1819 are issued without a matching secret. Clients MAY request an access 1820 token with a matching secret by specifying the desired secret type 1821 using the "secret_type" token request parameter. 1823 When an access token does not include a matching secret, the access 1824 token acts as a bearer token, where the token string is a shared 1825 symmetric secret. This requires treating the access token with the 1826 same care as other secrets (e.g. user passwords). Access tokens 1827 SHOULD NOT be sent in the clear over an insecure channel. 1829 However, when it is necessary to transmit bearer tokens in the clear 1830 without a secure channel, authorization servers SHOULD issue access 1831 tokens with limited scope and lifetime to reduce the potential risk 1832 from a compromised access token. Clients SHOULD request and utilize 1833 an access token with a matching secret when making protected resource 1834 requests over an insecure channel (e.g. an HTTP request without using 1835 TLS/SSL). 1837 When an access token includes a matching secret, the secret is not 1838 included directly in the request but is used instead to generate a 1839 cryptographic signature of the request. The signature can only be 1840 generated and verified by entities with access to the secret. 1842 Clients SHOULD NOT make authenticated requests with an access token 1843 to unfamiliar resource servers, especially when using bearer tokens, 1844 regardless of the presence of a secure channel. 1846 5.1. The Authorization Request Header 1848 The "Authorization" request header field is used by clients to make 1849 both bearer token and cryptographic token requests. When making 1850 bearer token requests, the client uses the "token" attribute to 1851 include the access token in the request without any of the other 1852 attributes. Additional methods for making bearer token requests are 1853 described in Section 5.2. 1855 For example: 1857 GET /resource HTTP/1.1 1858 Host: server.example.com 1859 Authorization: Token token="vF9dft4qmT" 1861 When making a cryptographic token request (using an access token with 1862 a matching secret) the client uses the "token" attribute to include 1863 the access token in the request, and uses the "nonce", "timestamp", 1864 "algorithm", and "signature" attributes to apply the matching secret. 1866 For example: 1868 GET /resource HTTP/1.1 1869 Host: server.example.com 1870 Authorization: Token token="vF9dft4qmT", 1871 nonce="s8djwd", 1872 timestamp="137131200", 1873 algorithm="hmac-sha256", 1874 signature="wOJIO9A2W5mFwDgiDvZbTSMK/PY=" 1876 The "Authorization" header field uses the framework defined by 1877 [RFC2617] as follows: 1879 credentials = "Token" RWS token-response 1881 token-response = token-id 1882 [ CS nonce ] 1883 [ CS timestamp ] 1884 [ CS algorithm ] 1885 [ CS signature ] 1887 token-id = "token" "=" <"> token <"> 1888 timestamp = "timestamp" "=" <"> 1*DIGIT <"> 1889 nonce = "nonce" "=" <"> token <"> 1891 algorithm = "algorithm" "=" algorithm-name 1892 algorithm-name = "hmac-sha256" / 1893 token 1895 signature = "signature" "=" <"> token <"> 1897 5.2. Bearer Token Requests 1899 Clients make bearer token requests by including the access token 1900 using the HTTP "Authorization" request header with the "Token" 1901 authentication scheme as described in Section 5.1. The access token 1902 is included using the "token" parameter. 1904 For example, the client makes the following HTTPS request: 1906 GET /resource HTTP/1.1 1907 Host: server.example.com 1908 Authorization: Token token="vF9dft4qmT" 1910 The resource server MUST validate the access token and ensure it has 1911 not expired and that its scope covers the requested resource. If the 1912 token expired or is invalid, the resource server MUST reply with an 1913 HTTP 401 status code (Unauthorized) and include the HTTP 1914 "WWW-Authenticate" response header as described in Section 6.1. 1916 For example: 1918 HTTP/1.1 401 Unauthorized 1919 WWW-Authenticate: Token realm='Service', error='token_expired' 1921 Alternatively, the client MAY include the access token using the HTTP 1922 request URI in the query component as described in Section 5.2.1, or 1923 in the HTTP body when using the "application/x-www-form-urlencoded" 1924 content type as described in Section 5.2.2. Clients SHOULD only use 1925 the request URI or body when the "Authorization" request header is 1926 not available, and MUST NOT use more than one method in each request. 1928 5.2.1. URI Query Parameter 1930 When including the access token in the HTTP request URI, the client 1931 adds the access token to the request URI query component as defined 1932 by [RFC3986] using the "oauth_token" parameter. 1934 For example, the client makes the following HTTPS request: 1936 GET /resource?oauth_token=vF9dft4qmT HTTP/1.1 1937 Host: server.example.com 1939 The HTTP request URI query can include other request-specific 1940 parameters, in which case, the "oauth_token" parameters SHOULD be 1941 appended following the request-specific parameters, properly 1942 separated by an "&" character (ASCII code 38). 1944 The resource server MUST validate the access token and ensure it has 1945 not expired and its scope includes the requested resource. If the 1946 resource expired or is not valid, the resource server MUST reply with 1947 an HTTP 401 status code (Unauthorized) and include the HTTP 1948 "WWW-Authenticate" response header as described in Section 6.1. 1950 5.2.2. Form-Encoded Body Parameter 1952 When including the access token in the HTTP request entity-body, the 1953 client adds the access token to the request body using the 1954 "oauth_token" parameter. The client can use this method only if the 1955 following REQUIRED conditions are met: 1957 o The entity-body is single-part. 1959 o The entity-body follows the encoding requirements of the 1960 "application/x-www-form-urlencoded" content-type as defined by 1961 [W3C.REC-html40-19980424]. 1963 o The HTTP request entity-header includes the "Content-Type" header 1964 field set to "application/x-www-form-urlencoded". 1966 o The HTTP request method is "POST", "PUT", or "DELETE". 1968 The entity-body can include other request-specific parameters, in 1969 which case, the "oauth_token" parameters SHOULD be appended following 1970 the request-specific parameters, properly separated by an "&" 1971 character (ASCII code 38). 1973 For example, the client makes the following HTTPS request: 1975 POST /resource HTTP/1.1 1976 Host: server.example.com 1977 Content-Type: application/x-www-form-urlencoded 1979 oauth_token=vF9dft4qmT 1981 The resource server MUST validate the access token and ensure it has 1982 not expired and its scope includes the requested resource. If the 1983 resource expired or is not valid, the resource server MUST reply with 1984 an HTTP 401 status code (Unauthorized) and include the HTTP 1985 "WWW-Authenticate" response header as described in Section 6.1. 1987 5.3. Cryptographic Tokens Requests 1989 Clients make authenticated protected resource requests using an 1990 access token with a matching secret by calculating a set of values 1991 and including them in the request using the "Authorization" header 1992 field. The way clients calculate these values depends on the access 1993 token secret type as issued by the authorization server. 1995 This specification defines the "hmac-sha256" algorithm, and 1996 establishes a registry for providing additional algorithms. Clients 1997 obtain an access token with a matching "hmac-sha256" secret by using 1998 the "secret_type" parameter when requesting an access token. 2000 5.3.1. The 'hmac-sha256' Algorithm 2002 The "hmac-sha256" algorithm uses the HMAC method as defined in 2003 [RFC2104] together with the SHA-256 hash function defined in [NIST 2004 FIPS-180-3] to apply the access token secret to the request and 2005 generate a signature value that is included in the request instead of 2006 transmitting the secret in the clear. 2008 To use the "hmac-sha256" algorithm, clients: 2010 1. Calculate the request timestamp and generate a request nonce as 2011 described in Section 5.3.1.1. 2013 2. Construct the normalized request string as described in 2014 Section 5.3.1.2. 2016 3. Calculate the request signature as described in Section 5.3.1.3. 2018 4. Include the timestamp, nonce, algorithm name, and calculated 2019 signature in the request using the "Authorization" header field. 2021 For example: 2023 GET /resource HTTP/1.1 2024 Host: server.example.com 2025 Authorization: Token token="vF9dft4qmT", 2026 nonce="s8djwd", 2027 timestamp="137131200", 2028 algorithm="hmac-sha256", 2029 signature="wOJIO9A2W5mFwDgiDvZbTSMK/PY=" 2031 The resource server MUST validate the access token and ensure it has 2032 not expired and that its scope covers the requested resource. The 2033 resource server MUST also recalculate the request signature using the 2034 attributes provided by the client and compare it to the signature 2035 provided. If the token expired or is invalid, or if the signature is 2036 incorrect, the resource server MUST reply with an HTTP 401 status 2037 code (Unauthorized) and include the HTTP "WWW-Authenticate" response 2038 header as described in Section 6.1. 2040 For example: 2042 HTTP/1.1 401 Unauthorized 2043 Date: Tue, 15 Nov 2010 08:12:31 GMT 2044 WWW-Authenticate: Token realm='Service', 2045 algorithms='hmac-sha256', 2046 error='invalid_signature' 2048 [[ Errors list ]] 2050 5.3.1.1. Nonce and Timestamp 2052 A timestamp in combination with unique nonce values is used to 2053 protect against replay attacks when transmitted over an insecure 2054 channel. 2056 The nonce is a random string, uniquely generated by the client to 2057 allow the resource server to verify that a request has never been 2058 made before and helps prevent replay attacks when requests are made 2059 over a non-secure channel. The nonce value MUST be unique across all 2060 requests with the same timestamp and token combinations. 2062 The timestamp value is the current time expressed in the number of 2063 seconds since January 1, 1970 00:00:00 GMT, and MUST be a positive 2064 integer. 2066 To avoid the need to retain an infinite number of nonce values for 2067 future checks, resource servers MAY choose to restrict the time 2068 period after which a request with an old timestamp is rejected. When 2069 resource servers apply such a restriction, clients SHOULD synchronize 2070 their clocks by using the resource server's time as indicated by the 2071 HTTP "Date" response header field as defined in [RFC2616]. 2073 5.3.1.2. Normalized String Construction 2075 The normalized request string is a consistent, reproducible 2076 concatenation of several of the HTTP request elements into a single 2077 string. The string is used as an input to the selected cryptographic 2078 method and includes the HTTP request method (e.g. "GET", "POST", 2079 etc.), the authority as declared by the HTTP "Host" request header, 2080 and the request resource URI. 2082 The normalized request string does not cover the entire HTTP request. 2083 Most notably, it does not include the entity-body or most HTTP 2084 entity-headers. It is important to note that the resource server 2085 cannot verify the authenticity of the excluded request elements 2086 without using additional protections such as TLS/SSL. 2088 The normalized request string is constructed by concatenating 2089 together, in order, the following HTTP request elements, separated by 2090 the "," character (ASCII code 44): 2092 1. The request timestamp as described in Section 5.3.1.1. 2094 2. The request nonce as described in Section 5.3.1.1. 2096 3. The cryptographic algorithm used. 2098 4. The HTTP request method in uppercase. For example: "HEAD", 2099 "GET", "POST", etc. 2101 5. The hostname, colon-separated (ASCII code 58) from the TCP port 2102 used to make the request as included in the HTTP request "Host" 2103 header field. The port MUST be included even if it is not 2104 included in the "Host" header field (i.e. the default port for 2105 the scheme). 2107 6. The request resource URI. 2109 For example, the normalized request string for the "GET" request URI 2110 "http://example.com/resource", request timestamp "137131200", request 2111 nonce "s8djwd", and "hmac-sha256" algorithm (line breaks are for 2112 display purposes only): 2114 137131200,s8djwd,hmac-sha256,GET,example.com:80, 2115 http://example.com/resource 2117 5.3.1.3. Signature Calculation 2119 Clients calculate the request signature using the HMAC-SHA256 2120 function: 2122 digest = HMAC-SHA256 (key, text) 2124 by setting the function variables are follows: 2126 text 2127 is set to the value of the normalize request string as 2128 described in Section 5.3.1.2. 2130 key 2131 is set to the access token secret. 2133 The request signature is the calculated value of the "digest" 2134 variable after the result octet string is base64-encoded per 2135 [RFC2045] section 6.8. 2137 6. Identifying a Protected Resource 2139 Clients access protected resources after locating the appropriate 2140 end-user and token endpoints and obtaining an access token. In many 2141 cases, interacting with a protected resource requires prior knowledge 2142 of the protected resource properties and methods, as well as its 2143 authentication requirements (i.e. establishing client identity, 2144 locating the end-user and token endpoints). 2146 However, there are cases in which clients are unfamiliar with the 2147 protected resource, including whether the resource requires 2148 authentication. When clients attempt to access an unfamiliar 2149 protected resource without an access token, the resource server 2150 denies the request and informs the client of the required credentials 2151 using an HTTP authentication challenge. 2153 In addition, when receiving an invalid authenticated request, the 2154 resource server issues an authentication challenge including the 2155 error type and message. 2157 6.1. The WWW-Authenticate Response Header 2159 A resource server receiving a request for a protected resource 2160 without a valid access token MUST respond with a 401 (Unauthorized) 2161 or 403 (Forbidden) HTTP status code, and include at least one "Token" 2162 "WWW-Authenticate" response header field challenge. 2164 The "WWW-Authenticate" header field uses the framework defined by 2165 [RFC2617] as follows: 2167 challenge = "Token" RWS token-challenge 2169 token-challenge = realm 2170 [ CS user-uri ] 2171 [ CS token-uri ] 2172 [ CS algorithms ] 2173 [ CS scope ] 2174 [ CS error ] 2176 user-uri = "user-uri" "=" URI-Reference 2177 token-uri = "token-uri" "=" URI-Reference 2178 algorithms = "algorithms" "=" <"> 1#algorithm-name <"> 2179 scope = "scope" "=" <"> 1#URI-Reference <"> 2180 error = "error" "=" <"> token <"> 2182 CS = OWS "," OWS 2184 The "realm" attribute is used to provide the protected resources 2185 partition as defined by [RFC2617]. 2187 The "user-uri" and "token-uri" attributes provide a way for the 2188 resource server to advertise the URIs of the end-user and token 2189 endpoints capable of issuing an access token suitable for accessing 2190 the requested resource. 2192 The "algorithms" attribute is a space-delimited list of the 2193 cryptographic algorithms supported by the resource server. The 2194 client MAY request an access token with a suitable matching secret by 2195 using the "secret_type" request parameter as described in 2196 Section 5.3. 2198 The "scope" attribute is a space-delimited list of URIs (relative or 2199 absolute) indicating the required scope of the access token for 2200 accessing the requested resource. 2202 The "error" attribute is used to inform the client the reason why an 2203 access request was declined. [[ Add list of error codes ]] 2205 7. Security Considerations 2207 [[ Todo ]] 2209 8. IANA Considerations 2211 [[ Not Yet ]] 2213 9. Acknowledgements 2215 [[ Add OAuth 1.0a authors + WG contributors ]] 2217 Appendix A. Differences from OAuth 1.0a 2219 [[ Todo ]] 2221 Appendix B. Document History 2223 [[ to be removed by RFC editor before publication as an RFC ]] 2225 -05 2227 o Corrected device example. 2229 o Added client credentials parameters to the assertion flow as 2230 OPTIONAL. 2232 o Added the ability to send client credentials using an HTTP 2233 authentication scheme. 2235 o Initial text for the "WWW-Authenticate" header (also added scope 2236 support). 2238 o Change authorization endpoint to end-user endpoint. 2240 o In the device flow, change the "user_uri" parameter to 2241 "verification_uri" to avoid confusion with the end-user endpoint. 2243 o Add "format" request parameter and support for XML and form- 2244 encoded responses. 2246 -04 2248 o Changed all token endpoints to use "POST" 2250 o Clarified the authorization server's ability to issue a new 2251 refresh token when refreshing a token. 2253 o Changed the flow categories to clarify the autonomous group. 2255 o Changed client credentials language not to always be server- 2256 issued. 2258 o Added a "scope" response parameter. 2260 o Fixed typos. 2262 o Fixed broken document structure. 2264 -03 2266 o Fixed typo in JSON error examples. 2268 o Fixed general typos. 2270 o Moved all flows sections up one level. 2272 -02 2274 o Removed restriction on "redirect_uri" including a query. 2276 o Added "scope" parameter. 2278 o Initial proposal for a JSON-based token response format. 2280 -01 2282 o Editorial changes based on feedback from Brian Eaton, Bill Keenan, 2283 and Chuck Mortimore. 2285 o Changed device flow "type" parameter values and switch to use only 2286 the token endpoint. 2288 -00 2290 o Initial draft based on a combination of WRAP and OAuth 1.0a. 2292 10. References 2294 10.1. Normative References 2296 [I-D.ietf-httpbis-p1-messaging] 2297 Fielding, R., Gettys, J., Mogul, J., Nielsen, H., 2298 Masinter, L., Leach, P., Berners-Lee, T., and J. Reschke, 2299 "HTTP/1.1, part 1: URIs, Connections, and Message 2300 Parsing", draft-ietf-httpbis-p1-messaging-09 (work in 2301 progress), March 2010. 2303 [NIST FIPS-180-3] 2304 National Institute of Standards and Technology, "Secure 2305 Hash Standard (SHS). FIPS PUB 180-3, October 2008". 2307 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 2308 Extensions (MIME) Part One: Format of Internet Message 2309 Bodies", RFC 2045, November 1996. 2311 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 2312 Hashing for Message Authentication", RFC 2104, 2313 February 1997. 2315 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2316 Requirement Levels", BCP 14, RFC 2119, March 1997. 2318 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 2319 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 2320 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 2322 [RFC2617] Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S., 2323 Leach, P., Luotonen, A., and L. Stewart, "HTTP 2324 Authentication: Basic and Digest Access Authentication", 2325 RFC 2617, June 1999. 2327 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. 2329 [RFC3023] Murata, M., St. Laurent, S., and D. Kohn, "XML Media 2330 Types", RFC 3023, January 2001. 2332 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 2333 Standards (PKCS) #1: RSA Cryptography Specifications 2334 Version 2.1", RFC 3447, February 2003. 2336 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 2337 10646", STD 63, RFC 3629, November 2003. 2339 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 2340 Resource Identifier (URI): Generic Syntax", STD 66, 2341 RFC 3986, January 2005. 2343 [RFC4627] Crockford, D., "The application/json Media Type for 2344 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 2346 [W3C.REC-html40-19980424] 2347 Hors, A., Raggett, D., and I. Jacobs, "HTML 4.0 2348 Specification", World Wide Web Consortium 2349 Recommendation REC-html40-19980424, April 1998, 2350 . 2352 10.2. Informative References 2354 [I-D.hammer-oauth] 2355 Hammer-Lahav, E., "The OAuth 1.0 Protocol", 2356 draft-hammer-oauth-10 (work in progress), February 2010. 2358 [I-D.hardt-oauth] 2359 Hardt, D., Tom, A., Eaton, B., and Y. Goland, "OAuth Web 2360 Resource Authorization Profiles", draft-hardt-oauth-01 2361 (work in progress), January 2010. 2363 [OASIS.saml-core-2.0-os] 2364 Cantor, S., Kemp, J., Philpott, R., and E. Maler, 2365 "Assertions and Protocol for the OASIS Security Assertion 2366 Markup Language (SAML) V2.0", OASIS Standard saml-core- 2367 2.0-os, March 2005. 2369 Authors' Addresses 2371 Eran Hammer-Lahav (editor) 2372 Yahoo! 2374 Email: eran@hueniverse.com 2375 URI: http://hueniverse.com 2377 David Recordon 2378 Facebook 2380 Email: davidrecordon@facebook.com 2381 URI: http://www.davidrecordon.com/ 2383 Dick Hardt 2385 Email: dick.hardt@gmail.com 2386 URI: http://dickhardt.org/