idnits 2.17.1 draft-ietf-oauth-v2-16.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 : ---------------------------------------------------------------------------- -- The draft header indicates that this document obsoletes RFC5849, but the abstract doesn't seem to mention this, which it should. 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 19, 2011) is 4723 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) ** 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 4627 (Obsoleted by RFC 7158, RFC 7159) ** Obsolete normative reference: RFC 5226 (Obsoleted by RFC 8126) ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) == Outdated reference: A later version (-23) exists of draft-ietf-oauth-saml2-bearer-03 == Outdated reference: A later version (-23) exists of draft-ietf-oauth-v2-bearer-04 == Outdated reference: A later version (-05) exists of draft-ietf-oauth-v2-http-mac-00 -- Obsolete informational reference (is this intentional?): RFC 5849 (Obsoleted by RFC 6749) Summary: 5 errors (**), 0 flaws (~~), 5 warnings (==), 3 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 Obsoletes: 5849 (if approved) D. Recordon 5 Intended status: Standards Track Facebook 6 Expires: November 20, 2011 D. Hardt 7 Microsoft 8 May 19, 2011 10 The OAuth 2.0 Authorization Protocol 11 draft-ietf-oauth-v2-16 13 Abstract 15 The OAuth 2.0 authorization protocol enables a third-party 16 application to obtain limited access to an HTTP service, either on 17 behalf of an end-user by orchestrating an approval interaction 18 between the end-user and the HTTP service, or by allowing the third- 19 party application to obtain access on its own behalf. 21 Status of this Memo 23 This Internet-Draft is submitted in full conformance with the 24 provisions of BCP 78 and BCP 79. 26 Internet-Drafts are working documents of the Internet Engineering 27 Task Force (IETF). Note that other groups may also distribute 28 working documents as Internet-Drafts. The list of current Internet- 29 Drafts is at http://datatracker.ietf.org/drafts/current/. 31 Internet-Drafts are draft documents valid for a maximum of six months 32 and may be updated, replaced, or obsoleted by other documents at any 33 time. It is inappropriate to use Internet-Drafts as reference 34 material or to cite them other than as "work in progress." 36 This Internet-Draft will expire on November 20, 2011. 38 Copyright Notice 40 Copyright (c) 2011 IETF Trust and the persons identified as the 41 document authors. All rights reserved. 43 This document is subject to BCP 78 and the IETF Trust's Legal 44 Provisions Relating to IETF Documents 45 (http://trustee.ietf.org/license-info) in effect on the date of 46 publication of this document. Please review these documents 47 carefully, as they describe your rights and restrictions with respect 48 to this document. Code Components extracted from this document must 49 include Simplified BSD License text as described in Section 4.e of 50 the Trust Legal Provisions and are provided without warranty as 51 described in the Simplified BSD License. 53 Table of Contents 55 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 56 1.1. Roles . . . . . . . . . . . . . . . . . . . . . . . . . . 5 57 1.2. Protocol Flow . . . . . . . . . . . . . . . . . . . . . . 5 58 1.3. Access Token . . . . . . . . . . . . . . . . . . . . . . 6 59 1.4. Authorization Grant . . . . . . . . . . . . . . . . . . . 7 60 1.5. Refresh Token . . . . . . . . . . . . . . . . . . . . . . 9 61 1.6. Document Structure . . . . . . . . . . . . . . . . . . . 11 62 1.7. Notational Conventions . . . . . . . . . . . . . . . . . 11 63 2. Protocol Endpoints . . . . . . . . . . . . . . . . . . . . . . 11 64 2.1. Authorization Endpoint . . . . . . . . . . . . . . . . . 12 65 2.2. Token Endpoint . . . . . . . . . . . . . . . . . . . . . 13 66 3. Client Authentication . . . . . . . . . . . . . . . . . . . . 14 67 3.1. Client Password Authentication . . . . . . . . . . . . . 15 68 3.2. Other Client Authentication Methods . . . . . . . . . . . 16 69 4. Obtaining Authorization . . . . . . . . . . . . . . . . . . . 16 70 4.1. Authorization Code . . . . . . . . . . . . . . . . . . . 16 71 4.2. Implicit Grant . . . . . . . . . . . . . . . . . . . . . 22 72 4.3. Resource Owner Password Credentials . . . . . . . . . . . 28 73 4.4. Client Credentials . . . . . . . . . . . . . . . . . . . 30 74 4.5. Extensions . . . . . . . . . . . . . . . . . . . . . . . 32 75 5. Issuing an Access Token . . . . . . . . . . . . . . . . . . . 33 76 5.1. Successful Response . . . . . . . . . . . . . . . . . . . 33 77 5.2. Error Response . . . . . . . . . . . . . . . . . . . . . 34 78 6. Refreshing an Access Token . . . . . . . . . . . . . . . . . . 36 79 7. Accessing Protected Resources . . . . . . . . . . . . . . . . 37 80 7.1. Access Token Types . . . . . . . . . . . . . . . . . . . 38 81 8. Extensibility . . . . . . . . . . . . . . . . . . . . . . . . 38 82 8.1. Defining Access Token Types . . . . . . . . . . . . . . . 38 83 8.2. Defining New Endpoint Parameters . . . . . . . . . . . . 39 84 8.3. Defining New Authorization Grant Types . . . . . . . . . 39 85 8.4. Defining Additional Error Codes . . . . . . . . . . . . . 39 86 9. Native Applications . . . . . . . . . . . . . . . . . . . . . 40 87 10. Security Considerations . . . . . . . . . . . . . . . . . . . 41 88 10.1. Client Authentication . . . . . . . . . . . . . . . . . . 42 89 10.2. Client Impersonation . . . . . . . . . . . . . . . . . . 42 90 10.3. Access Token Credentials . . . . . . . . . . . . . . . . 43 91 10.4. Refresh Tokens . . . . . . . . . . . . . . . . . . . . . 43 92 10.5. Request Confidentiality . . . . . . . . . . . . . . . . . 44 93 10.6. Endpoints Authenticity . . . . . . . . . . . . . . . . . 44 94 10.7. Credentials Guessing Attacks . . . . . . . . . . . . . . 44 95 10.8. Phishing Attacks . . . . . . . . . . . . . . . . . . . . 44 96 10.9. Authorization Codes . . . . . . . . . . . . . . . . . . . 45 97 10.10. Session Fixation . . . . . . . . . . . . . . . . . . . . 45 98 10.11. Redirection URI Validation . . . . . . . . . . . . . . . 46 99 10.12. Resource Owner Password Credentials . . . . . . . . . . . 46 100 10.13. XSRF/CSRF Prevention . . . . . . . . . . . . . . . . . . 46 101 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 46 102 11.1. The OAuth Access Token Type Registry . . . . . . . . . . 46 103 11.2. The OAuth Parameters Registry . . . . . . . . . . . . . . 48 104 11.3. The OAuth Extensions Error Registry . . . . . . . . . . . 51 105 12. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 52 106 Appendix A. Editor's Notes . . . . . . . . . . . . . . . . . . . 53 107 13. References . . . . . . . . . . . . . . . . . . . . . . . . . . 53 108 13.1. Normative References . . . . . . . . . . . . . . . . . . 53 109 13.2. Informative References . . . . . . . . . . . . . . . . . 54 110 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 55 112 1. Introduction 114 In the traditional client-server authentication model, the client 115 accesses a protected resource on the server by authenticating with 116 the server using the resource owner's credentials. In order to 117 provide third-party applications access to protected resources, the 118 resource owner shares its credentials with the third-party. This 119 creates several problems and limitations: 121 o Third-party applications are required to store the resource- 122 owner's credentials for future use, typically a password in clear- 123 text. 124 o Servers are required to support password authentication, despite 125 the security weaknesses created by passwords. 126 o Third-party applications gain overly broad access to the resource- 127 owner's protected resources, leaving resource owners without any 128 ability to restrict duration or access to a limited subset of 129 resources. 130 o Resource owners cannot revoke access to an individual third-party 131 without revoking access to all third-parties, and must do so by 132 changing their password. 134 OAuth addresses these issues by introducing an authorization layer 135 and separating the role of the client from that of the resource 136 owner. In OAuth, the client requests access to resources controlled 137 by the resource owner and hosted by the resource server, and is 138 issued a different set of credentials than those of the resource 139 owner. 141 Instead of using the resource owner's credentials to access protected 142 resources, the client obtains an access token - a string denoting a 143 specific scope, duration, and other access attributes. Access tokens 144 are issued to third-party clients by an authorization server with the 145 approval of the resource owner. The client uses the access token to 146 access the protected resources hosted by the resource server. 148 For example, a web end-user (resource owner) can grant a printing 149 service (client) access to her protected photos stored at a photo 150 sharing service (resource server), without sharing her username and 151 password with the printing service. Instead, she authenticates 152 directly with a server trusted by the photo sharing service 153 (authorization server) which issues the printing service delegation- 154 specific credentials (access token). 156 This specification is designed for use with HTTP [RFC2616]. The use 157 of OAuth with any transport protocol other than HTTP is undefined. 159 1.1. Roles 161 OAuth includes four roles working together to grant and provide 162 access to protected resources - access restricted resources which 163 require authentication to access: 165 resource owner 166 An entity capable of granting access to a protected resource. 167 When the resource owner is a person, it is referred to as an end- 168 user. 169 resource server 170 The server hosting the protected resources, capable of accepting 171 and responding to protected resource requests using access tokens. 172 client 173 An application making protected resource requests on behalf of the 174 resource owner and with its authorization. 175 authorization server 176 The server issuing access tokens to the client after successfully 177 authenticating the resource owner and obtaining authorization. 179 The interaction between the authorization server and resource server 180 is beyond the scope of this specification. The authorization server 181 may be the same server as the resource server or a separate entity. 182 A single authorization server may issue access tokens accepted by 183 multiple resource servers. 185 1.2. Protocol Flow 187 When interacting with the authorization server, the client identifies 188 itself using a set of client credentials which include a client 189 identifier and other authentication attributes. The means through 190 which the client obtains its credentials are beyond the scope of this 191 specification, but typically involve registration with the 192 authorization server. 194 +--------+ +---------------+ 195 | |--(A)- Authorization Request ->| Resource | 196 | | | Owner | 197 | |<-(B)-- Authorization Grant ---| | 198 | | +---------------+ 199 | | 200 | | Authorization Grant & +---------------+ 201 | |--(C)--- Client Credentials -->| Authorization | 202 | Client | | Server | 203 | |<-(D)----- Access Token -------| | 204 | | +---------------+ 205 | | 206 | | +---------------+ 207 | |--(E)----- Access Token ------>| Resource | 208 | | | Server | 209 | |<-(F)--- Protected Resource ---| | 210 +--------+ +---------------+ 212 Figure 1: Abstract Protocol Flow 214 The abstract flow illustrated in Figure 1 describes the interaction 215 between the four roles and includes the following steps: 217 (A) The client requests authorization from the resource owner. The 218 authorization request can be made directly to the resource owner 219 (as shown), or preferably indirectly via an intermediary such as 220 an authorization server. 221 (B) The client receives an authorization grant which represents the 222 authorization provided by the resource owner. The authorization 223 grant type depends on the method used by the client and 224 supported by the authorization server to obtain it. 225 (C) The client requests an access token by authenticating with the 226 authorization server using its client credentials (prearranged 227 between the client and authorization server) and presenting the 228 authorization grant. 229 (D) The authorization server validates the client credentials and 230 the authorization grant, and if valid issues an access token. 231 (E) The client requests the protected resource from the resource 232 server and authenticates by presenting the access token. 233 (F) The resource server validates the access token, and if valid, 234 serves the request. 236 1.3. Access Token 238 An access token is a string representing an authorization issued to 239 the client. The string is usually opaque to the client. Tokens 240 represent specific scopes and durations of access, granted by the 241 resource owner, and enforced by the resource server and authorization 242 server. 244 The token may denote an identifier used to retrieve the authorization 245 information, or self-contain the authorization information in a 246 verifiable manner (i.e. a token string consisting of some data and a 247 signature). Additional authentication credentials may be required in 248 order for the client to use a token. 250 The access token provides an abstraction layer, replacing different 251 authorization constructs (e.g. username and password) with a single 252 token understood by the resource server. This abstraction enables 253 issuing access tokens more restrictive than the authorization grant 254 used to obtain them, as well as removing the resource server's need 255 to understand a wide range of authentication methods. 257 Access tokens can have different formats, structures, and methods of 258 utilization (e.g. cryptographic properties) based on the resource 259 server security requirements. Access token attributes and the 260 methods used to access protected resources are beyond the scope of 261 this specification and are defined by companion specifications. 263 1.4. Authorization Grant 265 An authorization grant is a general term used to describe the 266 intermediate credentials representing the resource owner 267 authorization (to access its protected resources), and serves as an 268 abstraction layer. An authorization grant is used by the client to 269 obtain an access token. 271 This specification defines four grant types: authorization code, 272 implicit, resource owner password credentials, and client 273 credentials, as well as an extensibility mechanism for defining 274 additional types. 276 1.4.1. Authorization Code 278 The authorization code is obtained by using an authorization server 279 as an intermediary between the client and resource owner. Instead of 280 requesting authorization directly from the resource owner, the client 281 directs the resource owner to an authorization server (via its user- 282 agent as defined in [RFC2616]), which in turn directs the resource 283 owner back to the client with the authorization code. 285 Before directing the resource owner back to the client with the 286 authorization code, the authorization server authenticates the 287 resource owner and obtains authorization. Because the resource owner 288 only authenticates with the authorization server, the resource 289 owner's credentials are never shared with the client. 291 The authorization code provides a few important security benefits 292 such as the ability to authenticate the client and issuing the access 293 token directly to the client without potentially exposing it to 294 others, including the resource owner. 296 1.4.2. Implicit 298 When an access token is issued to the client directly as the result 299 of the resource owner authorization, without an intermediary 300 authorization grant (such as an authorization code), the grant is 301 considered implicit. 303 When issuing an implicit grant, the authorization server cannot 304 verify the identity of the client, and the access token may be 305 exposed to the resource owner or other applications with access to 306 the resource owner's user-agent. 308 Implicit grants improve the responsiveness and efficiency of some 309 clients (such as a client implemented as an in-browser application) 310 since it reduces the number of round trips required to obtain an 311 access token. 313 1.4.3. Resource Owner Password Credentials 315 The resource owner password credentials (e.g. a username and 316 password) can be used directly as an authorization grant to obtain an 317 access token. The credentials should only be used when there is a 318 high degree of trust between the resource owner and the client (e.g. 319 its computer operating system or a highly privileged application), 320 and when other authorization grant types are not available (such as 321 an authorization code). 323 Even though this grant type requires direct client access to the 324 resource owner credentials, the resource owner credentials are used 325 for a single request and are exchanged for an access token. Unlike 326 the HTTP Basic authentication scheme defined in [RFC2617], this grant 327 type (when combined with a refresh token) eliminates the need for the 328 client to store the resource-owner credentials for future use. 330 1.4.4. Client Credentials 332 The client credentials can be used as an authorization grant when the 333 authorization scope is limited to the protected resources under the 334 control of the client, or to protected resources previously arranged 335 with the authorization server. Client credentials are used as an 336 authorization grant typically when the client is acting on its own 337 behalf (the client is also the resource owner). 339 1.4.5. Extensions 341 Additional grant types may be defined to provide a bridge between 342 OAuth and other protocols. For example, 343 [I-D.ietf-oauth-saml2-bearer] defines a SAML 2.0 344 [OASIS.saml-core-2.0-os] bearer assertion grant type, which can be 345 used to obtain an access token. 347 1.5. Refresh Token 349 A refresh token is optionally issued by the authorization server to 350 the client together with an access token. The client can use the 351 refresh token to request another access token based on the same 352 authorization, without having to involve the resource owner again, or 353 having to retain the original authorization grant used to obtain the 354 initial access token. 356 A refresh token is a string representing the authorization granted to 357 the client by the resource owner. The string is usually opaque to 358 the client. The token may denote an identifier used to retrieve the 359 authorization information, or self-contain the authorization 360 information in a verifiable manner. The refresh token is bound to 361 the client it was issued to, and its usage requires client 362 authentication. 364 The refresh token can be used to obtain a new access token when the 365 current access token expires (access tokens may have a shorter 366 lifetime than authorized by the resource owner), no longer valid, or 367 to obtain additional access tokens with identical or narrower scope. 369 +--------+ Authorization Grant & +---------------+ 370 | |--(A)-------- Client Credentials --------->| | 371 | | | | 372 | |<-(B)----------- Access Token -------------| | 373 | | & Refresh Token | | 374 | | | | 375 | | +----------+ | | 376 | |--(C)---- Access Token ---->| | | | 377 | | | | | | 378 | |<-(D)- Protected Resource --| Resource | | Authorization | 379 | Client | | Server | | Server | 380 | |--(E)---- Access Token ---->| | | | 381 | | | | | | 382 | |<-(F)- Invalid Token Error -| | | | 383 | | +----------+ | | 384 | | | | 385 | | Refresh Token & | | 386 | |--(G)-------- Client Credentials --------->| | 387 | | | | 388 | |<-(H)----------- Access Token -------------| | 389 +--------+ & Optional Refresh Token +---------------+ 391 Figure 2: Refreshing an Expired Access Token 393 The flow illustrated in Figure 2 includes the following steps: 395 (A) The client requests an access token by authenticating with the 396 authorization server using its client credentials, and 397 presenting an authorization grant. 398 (B) The authorization server validates the client credentials and 399 the authorization grant, and if valid issues an access token and 400 a refresh token. 401 (C) The client makes a protected resource requests to the resource 402 server by presenting the access token. 403 (D) The resource server validates the access token, and if valid, 404 serves the request. 405 (E) Steps (C) and (D) repeat until the access token expires. If the 406 client knows the access token expired, it skips to step (G), 407 otherwise it makes another protected resource request. 408 (F) Since the access token is invalid, the resource server returns 409 an invalid token error. 410 (G) The client requests a new access token by authenticating with 411 the authorization server using its client credentials, and 412 presenting the refresh token. 414 (H) The authorization server validates the client credentials and 415 the refresh token, and if valid issues a new access token (and 416 optionally, a new refresh token). 418 1.6. Document Structure 420 This specification is organized into the following sections: 422 o Section 2 - describes the two endpoints used to obtain and utilize 423 the various authorization grant types. 424 o Section 3 - describes client identification and authentication in 425 general, and provides one such method for client authentication 426 using password credentials. 427 o Section 4 - describes the complete flow for each authorization 428 grant type, including requesting authorization, authorization 429 response, and requesting an access token. 430 o Section 5 - describes the common access token response used for 431 all non-implicit authorization grant types. 432 o Section 6 - describes the use of a refresh token to obtain 433 additional access tokens using the same resource owner 434 authorization. 435 o Section 7 - describes how access tokens are used to access 436 protected resources. 437 o Section 8 - describes how to extend certain elements of the 438 protocol. 439 o Section 9 - provides a security analysis of the protocol. 441 1.7. Notational Conventions 443 The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL NOT', 444 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'MAY', and 'OPTIONAL' in this 445 specification are to be interpreted as described in [RFC2119]. 447 This specification uses the Augmented Backus-Naur Form (ABNF) 448 notation of [RFC5234]. 450 Unless otherwise noted, all the protocol parameter names and values 451 are case sensitive. 453 2. Protocol Endpoints 455 The authorization process utilizes two endpoints (HTTP resources): 457 o Authorization endpoint - used to obtain authorization from the 458 resource owner via user-agent redirection. 460 o Token endpoint - used to exchange an authorization grant for an 461 access token, typically with client authentication. 463 Not every authorization grant type utilizes both endpoints. 464 Extension grant types MAY define additional endpoints as needed. 466 2.1. Authorization Endpoint 468 The authorization endpoint is used to interact with the resource 469 owner and obtain authorization which is expressed explicitly as an 470 authorization code (exchanged for an access token), or implicitly by 471 direct issuance of an access token. 473 The authorization server MUST first verify the identity of the 474 resource owner. The way in which the authorization server 475 authenticates the resource owner (e.g. username and password login, 476 session cookies) is beyond the scope of this specification. 478 The means through which the client obtains the location of the 479 authorization endpoint are beyond the scope of this specification but 480 is typically provided in the service documentation. The endpoint URI 481 MAY include a query component as defined by [RFC3986] section 3, 482 which MUST be retained when adding additional query parameters. 484 Since requests to the authorization endpoint result in user 485 authentication and the transmission of clear-text credentials (in the 486 HTTP response), the authorization server MUST require the use of a 487 transport-layer security mechanism when sending requests to the 488 authorization endpoint. The authorization server MUST support TLS 489 1.2 as defined in [RFC5246], and MAY support additional transport- 490 layer mechanisms meeting its security requirements. 492 The authorization server MUST support the use of the HTTP "GET" 493 method [RFC2616] for the authorization endpoint, and MAY support the 494 use of the "POST" method as well. 496 The REQUIRED "response_type" request parameter is used to identify 497 which grant type the client is requesting: authorization code or 498 implicit, described in Section 4.1.1 and Section 4.2.1 respectively. 499 If the request is missing the "response_type" parameter, the 500 authorization server SHOULD return an error response as described in 501 Section 4.1.2.1. 503 Parameters sent without a value MUST be treated as if they were 504 omitted from the request. The authorization server SHOULD ignore 505 unrecognized request parameters. 507 Request and response parameters MUST NOT repeat more than once, 508 unless noted otherwise. 510 2.1.1. Redirection URI 512 The client directs the resource owner's user-agent to the 513 authorization endpoint and includes a redirection URI to which the 514 authorization server will redirect the user-agent back once 515 authorization has been obtained (or denied). The client MAY omit the 516 redirection URI if one has been established between the client and 517 authorization server via other means, such as during the client 518 registration process. 520 The redirection URI MUST be an absolute URI and MAY include a query 521 component, which MUST be retained by the authorization server when 522 adding additional query parameters. 524 The authorization server SHOULD require the client to pre-register 525 their redirection URI or at least certain components such as the 526 scheme, host, port and path. If a redirection URI was registered, 527 the authorization server MUST compare any redirection URI received at 528 the authorization endpoint with the registered URI. 530 The authorization server SHOULD NOT redirect the user-agent to 531 unregistered or untrusted URIs to prevent the endpoint from being 532 used as an open redirector. If no valid redirection URI is 533 available, the authorization server SHOULD inform the resource owner 534 directly of the error. 536 2.2. Token Endpoint 538 The token endpoint is used by the client to obtain an access token by 539 authenticating with the authorization server and presenting its 540 authorization grant or refresh token. The token endpoint is used 541 with every authorization grant except for the implicit grant type 542 (since an access token is issued directly). 544 The means through which the client obtains the location of the token 545 endpoint are beyond the scope of this specification but is typically 546 provided in the service documentation. The endpoint URI MAY include 547 a query component, which MUST be retained when adding additional 548 query parameters. 550 Since requests to the token endpoint result in the transmission of 551 clear-text credentials (in the HTTP request and response), the 552 authorization server MUST require the use of a transport-layer 553 security mechanism when sending requests to the token endpoint. The 554 authorization server MUST support TLS 1.2 as defined in [RFC5246], 555 and MAY support additional transport-layer mechanisms meeting its 556 security requirements. 558 The token endpoint requires client authentication as described in 559 Section 3. The authorization server MAY accept any form of client 560 authentication meeting its security requirements. The client MUST 561 NOT use more than one authentication method in each request. 563 The client MUST use the HTTP "POST" method when making access token 564 requests. 566 Parameters sent without a value MUST be treated as if they were 567 omitted from the request. The authorization server SHOULD ignore 568 unrecognized request parameters. 570 Request and response parameters MUST NOT repeat more than once, 571 unless noted otherwise. 573 3. Client Authentication 575 Client credentials are used to identify and authenticate the client. 576 The client credentials include a client identifier - a unique string 577 issued to the client to identify itself to the authorization server. 578 The client identifier is not a secret, it is exposed to the resource 579 owner, and MUST NOT be used alone for client authentication. Client 580 authentication is accomplished via additional means such as a 581 matching client password. 583 The methods through which the client obtains its client credentials 584 are beyond the scope of this specification. However, the client 585 registration process typically includes gathering relevant 586 information which is used to educate the resource owner about the 587 client when requesting authorization. 589 Due to the nature of some clients, the authorization server should 590 not make assumptions about the confidentiality of client credentials 591 without establishing trust with the client. The authorization server 592 SHOULD NOT issue client credentials to clients incapable of keeping 593 their credentials confidential (typically determined during the 594 client registration process). 596 In addition, the authorization server MAY allow unauthenticated 597 access token requests when the client identity does not matter (e.g. 598 anonymous client) or when the client identity is established via 599 other means. For readability purposes only, this specification is 600 written under the assumption that the authorization server requires 601 some form of client authentication. However, such language does not 602 affect the authorization server's discretion in allowing 603 unauthenticated client requests. 605 3.1. Client Password Authentication 607 [[ Pending Consensus ]] 609 Clients in possession of client password credentials (the client 610 identifier together with a shared symmetric secret) MAY use the HTTP 611 Basic authentication scheme as defined in [RFC2617] to authenticate 612 with the authorization server. The client identifier is used as the 613 username, and the secret is used as the password. 615 When using the HTTP Basic authentication scheme, the client 616 identifier is included twice in the request (in the "Authorization" 617 header and in the "client_id" parameter). The authorization server 618 MUST ensure the two identifiers belong to the same client. 620 For example (extra line breaks are for display purposes only): 622 POST /token HTTP/1.1 623 Host: server.example.com 624 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW 625 Content-Type: application/x-www-form-urlencoded 627 grant_type=authorization_code&client_id=s6BhdRkqt3& 628 code=i1WsRn1uB1& 629 redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb 631 Alternatively, the authorization server MAY allow including the 632 client secret in the request body using the following parameter: 634 client_secret 635 REQUIRED. The client secret. 637 The use of the "client_secret" parameter is NOT RECOMMENDED, and 638 should be limited to clients unable to directly utilize the HTTP 639 Basic authentication scheme. 641 For example (extra line breaks are for display purposes only): 643 POST /token HTTP/1.1 644 Host: server.example.com 645 Content-Type: application/x-www-form-urlencoded 647 grant_type=authorization_code&client_id=s6BhdRkqt3& 648 client_secret=gX1fBat3bV&code=i1WsRn1uB1& 649 redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb 651 Since requests using this authentication method result in the 652 transmission of clear-text credentials, the authorization server MUST 653 require the use of a transport-layer security mechanism when sending 654 requests to the token endpoint. 656 3.2. Other Client Authentication Methods 658 The authorization server MAY support any suitable HTTP authentication 659 scheme matching its security requirements. When using other 660 authentication methods, the authorization server MUST define a 661 mapping between the client identifier and the credentials used to 662 authenticate. 664 4. Obtaining Authorization 666 To request an access token, the client obtains authorization from the 667 resource owner. The authorization is expressed in the form of an 668 authorization grant which the client uses to request the access 669 token. OAuth defines four grant types: authorization code, implicit, 670 resource owner password credentials, and client credentials. It also 671 provides an extension mechanism for defining additional grant types. 673 4.1. Authorization Code 675 The authorization code grant type is suitable for clients capable of 676 maintaining their client credentials confidential (for authenticating 677 with the authorization server) such as a client implemented on a 678 secure server. As a redirection-based flow, the client must be 679 capable of interacting with the resource owner's user-agent 680 (typically a web browser) and capable of receiving incoming requests 681 (via redirection) from the authorization server. 683 +----------+ 684 | resource | 685 | owner | 686 | | 687 +----------+ 688 ^ 689 | 690 (B) 691 +----|-----+ Client Identifier +---------------+ 692 | -+----(A)--- & Redirect URI ------>| | 693 | User- | | Authorization | 694 | Agent -+----(B)-- User authenticates --->| Server | 695 | | | | 696 | -+----(C)-- Authorization Code ---<| | 697 +-|----|---+ +---------------+ 698 | | ^ v 699 (A) (C) | | 700 | | | | 701 ^ v | | 702 +---------+ | | 703 | |>---(D)-- Client Credentials, --------' | 704 | | Authorization Code, | 705 | Client | & Redirect URI | 706 | | | 707 | |<---(E)----- Access Token -------------------' 708 +---------+ (w/ Optional Refresh Token) 710 Figure 3: Authorization Code Flow 712 The flow illustrated in Figure 3 includes the following steps: 714 (A) The client initiates the flow by directing the resource owner's 715 user-agent to the authorization endpoint. The client includes 716 its client identifier, requested scope, local state, and a 717 redirection URI to which the authorization server will send the 718 user-agent back once access is granted (or denied). 719 (B) The authorization server authenticates the resource owner (via 720 the user-agent) and establishes whether the resource owner 721 grants or denies the client's access request. 722 (C) Assuming the resource owner grants access, the authorization 723 server redirects the user-agent back to the client using the 724 redirection URI provided earlier. The redirection URI includes 725 an authorization code and any local state provided by the client 726 earlier. 728 (D) The client requests an access token from the authorization 729 server's token endpoint by authenticating using its client 730 credentials, and includes the authorization code received in the 731 previous step. The client includes the redirection URI used to 732 obtain the authorization code for verification. 733 (E) The authorization server validates the client credentials, the 734 authorization code, and ensures the redirection URI received 735 matches the URI used to redirect the client in step (C). If 736 valid, responds back with an access token. 738 4.1.1. Authorization Request 740 The client constructs the request URI by adding the following 741 parameters to the query component of the authorization endpoint URI 742 using the "application/x-www-form-urlencoded" format as defined by 743 [W3C.REC-html401-19991224]: 745 response_type 746 REQUIRED. Value MUST be set to "code". 747 client_id 748 REQUIRED. The client identifier as described in Section 3. 749 redirect_uri 750 REQUIRED, unless a redirection URI has been established between 751 the client and authorization server via other means. Described 752 in Section 2.1.1. 753 scope 754 OPTIONAL. The scope of the access request expressed as a list 755 of space-delimited, case sensitive strings. The value is 756 defined by the authorization server. If the value contains 757 multiple space-delimited strings, their order does not matter, 758 and each string adds an additional access range to the 759 requested scope. 760 state 761 OPTIONAL. An opaque value used by the client to maintain state 762 between the request and callback. The authorization server 763 includes this value when redirecting the user-agent back to the 764 client. 766 The client directs the resource owner to the constructed URI using an 767 HTTP redirection response, or by other means available to it via the 768 user-agent. 770 For example, the client directs the user-agent to make the following 771 HTTP request using transport-layer security (extra line breaks are 772 for display purposes only): 774 GET /authorize?response_type=code&client_id=s6BhdRkqt3& 775 redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb HTTP/1.1 776 Host: server.example.com 778 The authorization server validates the request to ensure all required 779 parameters are present and valid. If the request is valid, the 780 authorization server authenticates the resource owner and obtains an 781 authorization decision (by asking the resource owner or by 782 establishing approval via other means). 784 When a decision is established, the authorization server directs the 785 user-agent to the provided client redirection URI using an HTTP 786 redirection response, or by other means available to it via the user- 787 agent. 789 4.1.2. Authorization Response 791 If the resource owner grants the access request, the authorization 792 server issues an authorization code and delivers it to the client by 793 adding the following parameters to the query component of the 794 redirection URI using the "application/x-www-form-urlencoded" format: 796 code 797 REQUIRED. The authorization code generated by the 798 authorization server. The authorization code SHOULD expire 799 shortly after it is issued to minimize the risk of leaks. The 800 client MUST NOT reuse the authorization code. If an 801 authorization code is used more than once, the authorization 802 server MAY revoke all tokens previously issued based on that 803 authorization code. The authorization code is bound to the 804 client identifier and redirection URI. 805 state 806 REQUIRED if the "state" parameter was present in the client 807 authorization request. Set to the exact value received from 808 the client. 810 For example, the authorization server redirects the user-agent by 811 sending the following HTTP response: 813 HTTP/1.1 302 Found 814 Location: https://client.example.com/cb?code=i1WsRn1uB1 816 The client SHOULD ignore unrecognized response parameters. The 817 authorization code string size is left undefined by this 818 specification. The client should avoid making assumptions about code 819 value sizes. The authorization server should document the size of 820 any value it issues. 822 4.1.2.1. Error Response 824 If the request fails due to a missing, invalid, or mismatching 825 redirection URI, or if the client identifier provided is invalid, the 826 authorization server SHOULD inform the resource owner of the error, 827 and MUST NOT redirect the user-agent to the invalid redirection URI. 829 If the resource owner denies the access request or if the request 830 fails for reasons other than a missing or invalid redirection URI, 831 the authorization server informs the client by adding the following 832 parameters to the query component of the redirection URI using the 833 "application/x-www-form-urlencoded" format: 835 error 836 REQUIRED. A single error code from the following: 837 invalid_request 838 The request is missing a required parameter, includes an 839 unsupported parameter or parameter value, or is otherwise 840 malformed. 841 unauthorized_client 842 The client is not authorized to request an authorization 843 code using this method. 844 access_denied 845 The resource owner or authorization server denied the 846 request. 847 unsupported_response_type 848 The authorization server does not support obtaining an 849 authorization code using this method. 850 invalid_scope 851 The requested scope is invalid, unknown, or malformed. 852 a 4xx or 5xx HTTP status code (except for 400 and 401) 853 The authorization server MAY set the "error" parameter 854 value to a numerical HTTP status code from the 4xx or 5xx 855 range, with the exception of the 400 (Bad Request) and 856 401 (Unauthorized) status codes. For example, if the 857 service is temporarily unavailable, the authorization 858 server MAY return an error response with "error" set to 859 "503". 860 error_description 861 OPTIONAL. A human-readable text providing additional 862 information, used to assist in the understanding and resolution 863 of the error occurred. [[ add language and encoding information 864 ]] 866 error_uri 867 OPTIONAL. A URI identifying a human-readable web page with 868 information about the error, used to provide the resource owner 869 with additional information about the error. 870 state 871 REQUIRED if a valid "state" parameter was present in the client 872 authorization request. Set to the exact value received from 873 the client. 875 For example, the authorization server redirects the user-agent by 876 sending the following HTTP response: 878 HTTP/1.1 302 Found 879 Location: https://client.example.com/cb?error=access_denied 881 4.1.3. Access Token Request 883 The client makes a request to the token endpoint by adding the 884 following parameters using the "application/x-www-form-urlencoded" 885 format in the HTTP request entity-body: 887 grant_type 888 REQUIRED. Value MUST be set to "authorization_code". 889 client_id 890 REQUIRED. The client identifier as described in Section 3. 891 code 892 REQUIRED. The authorization code received from the 893 authorization server. 894 redirect_uri 895 REQUIRED. The redirection URI used by the authorization server 896 to return the authorization response in the previous step. 898 The client includes its authentication credentials as described in 899 Section 3 901 For example, the client makes the following HTTP using transport- 902 layer security (extra line breaks are for display purposes only): 904 POST /token HTTP/1.1 905 Host: server.example.com 906 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW 907 Content-Type: application/x-www-form-urlencoded 909 grant_type=authorization_code&client_id=s6BhdRkqt3& 910 code=i1WsRn1uB1& 911 redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb 913 The authorization server MUST: 915 o Validate the client credentials and ensure that the authorization 916 code was issued to that client. 917 o Verify that the authorization code is valid, and that the 918 redirection URI matches the redirection URI used by the 919 authorization server to deliver the authorization code. 921 4.1.4. Access Token Response 923 If the access token request is valid and authorized, the 924 authorization server issues an access token and optional refresh 925 token as described in Section 5.1. If the request client 926 authentication failed or is invalid, the authorization server returns 927 an error response as described in Section 5.2. 929 An example successful response: 931 HTTP/1.1 200 OK 932 Content-Type: application/json 933 Cache-Control: no-store 935 { 936 "access_token":"SlAV32hkKG", 937 "token_type":"example", 938 "expires_in":3600, 939 "refresh_token":"8xLOxBtZp8", 940 "example_parameter":"example_value" 941 } 943 4.2. Implicit Grant 945 The implicit grant type is suitable for clients incapable of 946 maintaining their client credentials confidential (for authenticating 947 with the authorization server) such as client applications residing 948 in a user-agent, typically implemented in a browser using a scripting 949 language such as JavaScript. 951 As a redirection-based flow, the client must be capable of 952 interacting with the resource owner's user-agent (typically a web 953 browser) and capable of receiving incoming requests (via redirection) 954 from the authorization server. 956 Unlike the authorization code grant type in which the client makes 957 separate requests for authorization and access token, the client 958 receives the access token as the result of the authorization request. 960 Using the implicit grant type does not include client authentication 961 since the client is unable to maintain their credential 962 confidentiality (the client resides on the resource owner's computer 963 or device which makes the client credentials accessible and 964 exploitable). Because the access token is encoded into the 965 redirection URI, it may be exposed to the resource owner and other 966 applications residing on its computer or device. 968 +----------+ 969 | Resource | 970 | Owner | 971 | | 972 +----------+ 973 ^ 974 | 975 (B) 976 +----|-----+ Client Identifier +---------------+ 977 | -+----(A)--- & Redirect URI ----->| | 978 | User- | | Authorization | 979 | Agent -|----(B)-- User authenticates -->| Server | 980 | | | | 981 | |<---(C)---- Redirect URI ------<| | 982 | | with Access Token +---------------+ 983 | | in Fragment 984 | | +---------------+ 985 | |----(D)---- Redirect URI ------>| Web Server | 986 | | without Fragment | with Client | 987 | | | Resource | 988 | (F) |<---(E)------- Script ---------<| | 989 | | +---------------+ 990 +-|--------+ 991 | | 992 (A) (G) Access Token 993 | | 994 ^ v 995 +---------+ 996 | | 997 | Client | 998 | | 999 +---------+ 1001 Figure 4: Implicit Grant Flow 1003 The flow illustrated in Figure 4 includes the following steps: 1005 (A) The client initiates the flow by directing the resource owner's 1006 user-agent to the authorization endpoint. The client includes 1007 its client identifier, requested scope, local state, and a 1008 redirection URI to which the authorization server will send the 1009 user-agent back once access is granted (or denied). 1010 (B) The authorization server authenticates the resource owner (via 1011 the user-agent) and establishes whether the resource owner 1012 grants or denies the client's access request. 1013 (C) Assuming the resource owner grants access, the authorization 1014 server redirects the user-agent back to the client using the 1015 redirection URI provided earlier. The redirection URI includes 1016 the access token in the URI fragment. 1017 (D) The user-agent follows the redirection instructions by making a 1018 request to the web server (does not include the fragment). The 1019 user-agent retains the fragment information locally. 1020 (E) The web server returns a web page (typically an HTML document 1021 with an embedded script) capable of accessing the full 1022 redirection URI including the fragment retained by the user- 1023 agent, and extracting the access token (and other parameters) 1024 contained in the fragment. 1025 (F) The user-agent executes the script provided by the web server 1026 locally, which extracts the access token and passes it to the 1027 client. 1029 4.2.1. Authorization Request 1031 The client constructs the request URI by adding the following 1032 parameters to the query component of the authorization endpoint URI 1033 using the "application/x-www-form-urlencoded" format: 1035 response_type 1036 REQUIRED. Value MUST be set to "token". 1037 client_id 1038 REQUIRED. The client identifier as described in Section 3. 1039 redirect_uri 1040 REQUIRED, unless a redirection URI has been established between 1041 the client and authorization server via other means. Described 1042 in Section 2.1.1. 1043 scope 1044 OPTIONAL. The scope of the access request expressed as a list 1045 of space-delimited, case sensitive strings. The value is 1046 defined by the authorization server. If the value contains 1047 multiple space-delimited strings, their order does not matter, 1048 and each string adds an additional access range to the 1049 requested scope. 1051 state 1052 OPTIONAL. An opaque value used by the client to maintain state 1053 between the request and callback. The authorization server 1054 includes this value when redirecting the user-agent back to the 1055 client. 1057 The client directs the resource owner to the constructed URI using an 1058 HTTP redirection response, or by other means available to it via the 1059 user-agent. 1061 For example, the client directs the user-agent to make the following 1062 HTTP request using transport-layer security (extra line breaks are 1063 for display purposes only): 1065 GET /authorize?response_type=token&client_id=s6BhdRkqt3& 1066 redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb HTTP/1.1 1067 Host: server.example.com 1069 The authorization server validates the request to ensure all required 1070 parameters are present and valid. If the request is valid, the 1071 authorization server authenticates the resource owner and obtains an 1072 authorization decision (by asking the resource owner or by 1073 establishing approval via other means). 1075 When a decision is established, the authorization server directs the 1076 user-agent to the provided client redirection URI using an HTTP 1077 redirection response, or by other means available to it via the user- 1078 agent. 1080 4.2.2. Access Token Response 1082 If the resource owner grants the access request, the authorization 1083 server issues an access token and delivers it to the client by adding 1084 the following parameters to the fragment component of the redirection 1085 URI using the "application/x-www-form-urlencoded" format: 1087 access_token 1088 REQUIRED. The access token issued by the authorization server. 1089 token_type 1090 REQUIRED. The type of the token issued as described in 1091 Section 7.1. Value is case insensitive. 1092 expires_in 1093 OPTIONAL. The duration in seconds of the access token 1094 lifetime. For example, the value "3600" denotes that the 1095 access token will expire in one hour from the time the response 1096 was generated. 1098 scope 1099 OPTIONAL. The scope of the access request expressed as a list 1100 of space-delimited, case sensitive strings. The value is 1101 defined by the authorization server. If the value contains 1102 multiple space-delimited strings, their order does not matter, 1103 and each string adds an additional access range to the 1104 requested scope. The authorization server SHOULD include the 1105 parameter if the requested scope is different from the one 1106 requested by the client. 1107 state 1108 REQUIRED if the "state" parameter was present in the client 1109 authorization request. Set to the exact value received from 1110 the client. 1112 For example, the authorization server redirects the user-agent by 1113 sending the following HTTP response (URI extra line breaks are for 1114 display purposes only): 1116 HTTP/1.1 302 Found 1117 Location: http://example.com/rd#access_token=FJQbwq9& 1118 token_type=example&expires_in=3600 1120 The client SHOULD ignore unrecognized response parameters. The 1121 access token string size is left undefined by this specification. 1122 The client should avoid making assumptions about value sizes. The 1123 authorization server should document the size of any value it issues. 1125 4.2.2.1. Error Response 1127 If the request fails due to a missing, invalid, or mismatching 1128 redirection URI, or if the client identifier provided is invalid, the 1129 authorization server SHOULD inform the resource owner of the error, 1130 and MUST NOT redirect the user-agent to the invalid redirection URI. 1132 If the resource owner denies the access request or if the request 1133 fails for reasons other than a missing or invalid redirection URI, 1134 the authorization server informs the client by adding the following 1135 parameters to the fragment component of the redirection URI using the 1136 "application/x-www-form-urlencoded" format: 1138 error 1139 REQUIRED. A single error code from the following: 1141 invalid_request 1142 The request is missing a required parameter, includes an 1143 unsupported parameter or parameter value, or is otherwise 1144 malformed. 1145 unauthorized_client 1146 The client is not authorized to request an access token 1147 using this method. 1148 access_denied 1149 The resource owner or authorization server denied the 1150 request. 1151 unsupported_response_type 1152 The authorization server does not support obtaining an 1153 access token using this method. 1154 invalid_scope 1155 The requested scope is invalid, unknown, or malformed. 1156 a 4xx or 5xx HTTP status code (except for 400 and 401) 1157 The authorization server MAY set the "error" parameter 1158 value to a numerical HTTP status code from the 4xx or 5xx 1159 range, with the exception of the 400 (Bad Request) and 1160 401 (Unauthorized) status codes. For example, if the 1161 service is temporarily unavailable, the authorization 1162 server MAY return an error response with "error" set to 1163 "503". 1164 error_description 1165 OPTIONAL. A human-readable text providing additional 1166 information, used to assist in the understanding and resolution 1167 of the error occurred. [[ add language and encoding information 1168 ]] 1169 error_uri 1170 OPTIONAL. A URI identifying a human-readable web page with 1171 information about the error, used to provide the resource owner 1172 with additional information about the error. 1173 state 1174 REQUIRED if a valid "state" parameter was present in the client 1175 authorization request. Set to the exact value received from 1176 the client. 1178 For example, the authorization server redirects the user-agent by 1179 sending the following HTTP response: 1181 HTTP/1.1 302 Found 1182 Location: https://client.example.com/cb#error=access_denied 1184 4.3. Resource Owner Password Credentials 1186 The resource owner password credentials grant type is suitable in 1187 cases where the resource owner has a trust relationship with the 1188 client, such as its computer operating system or a highly privileged 1189 application. The authorization server should take special care when 1190 enabling the grant type, and only when other flows are not viable. 1192 The grant type is suitable for clients capable of obtaining the 1193 resource owner credentials (username and password, typically using an 1194 interactive form). It is also used to migrate existing clients using 1195 direct authentication schemes such as HTTP Basic or Digest 1196 authentication to OAuth by converting the stored credentials with an 1197 access token. 1199 +----------+ 1200 | Resource | 1201 | Owner | 1202 | | 1203 +----------+ 1204 v 1205 | 1206 (A) Password Credentials 1207 | 1208 v 1209 +---------+ +---------------+ 1210 | | Client Credentials | | 1211 | |>--(B)---- & Resource Owner ----->| | 1212 | Client | Password Credentials | Authorization | 1213 | | | Server | 1214 | |<--(C)---- Access Token ---------<| | 1215 | | (w/ Optional Refresh Token) | | 1216 +---------+ +---------------+ 1218 Figure 5: Resource Owner Password Credentials Flow 1220 The flow illustrated in Figure 5 includes the following steps: 1222 (A) The resource owner provides the client with its username and 1223 password. 1224 (B) The client requests an access token from the authorization 1225 server's token endpoint by authenticating using its client 1226 credentials, and includes the credentials received from the 1227 resource owner. 1229 (C) The authorization server validates the resource owner 1230 credentials and the client credentials and issues an access 1231 token. 1233 4.3.1. Authorization Request and Response 1235 The method through which the client obtains the resource owner 1236 credentials is beyond the scope of this specification. The client 1237 MUST discard the credentials once an access token has been obtained. 1239 4.3.2. Access Token Request 1241 The client makes a request to the token endpoint by adding the 1242 following parameters using the "application/x-www-form-urlencoded" 1243 format in the HTTP request entity-body: 1245 grant_type 1246 REQUIRED. Value MUST be set to "password". 1247 client_id 1248 REQUIRED. The client identifier as described in Section 3. 1249 username 1250 REQUIRED. The resource owner username, encoded as UTF-8. 1251 password 1252 REQUIRED. The resource owner password, encoded as UTF-8. 1253 scope 1254 OPTIONAL. The scope of the access request expressed as a list 1255 of space-delimited, case sensitive strings. The value is 1256 defined by the authorization server. If the value contains 1257 multiple space-delimited strings, their order does not matter, 1258 and each string adds an additional access range to the 1259 requested scope. 1261 The client includes its authentication credentials as described in 1262 Section 3 1264 For example, the client makes the following HTTP request using 1265 transport-layer security (extra line breaks are for display purposes 1266 only): 1268 POST /token HTTP/1.1 1269 Host: server.example.com 1270 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW 1271 Content-Type: application/x-www-form-urlencoded 1273 grant_type=password&client_id=s6BhdRkqt3& 1274 username=johndoe&password=A3ddj3w 1276 The authorization server MUST: 1278 o Validate the client credentials. 1279 o Validate the resource owner password credentials. 1281 4.3.3. Access Token Response 1283 If the access token request is valid and authorized, the 1284 authorization server issues an access token and optional refresh 1285 token as described in Section 5.1. If the request failed client 1286 authentication or is invalid, the authorization server returns an 1287 error response as described in Section 5.2. 1289 An example successful response: 1291 HTTP/1.1 200 OK 1292 Content-Type: application/json 1293 Cache-Control: no-store 1295 { 1296 "access_token":"SlAV32hkKG", 1297 "token_type":"example", 1298 "expires_in":3600, 1299 "refresh_token":"8xLOxBtZp8", 1300 "example_parameter":"example_value" 1301 } 1303 4.4. Client Credentials 1305 The client can request an access token using only its client 1306 credentials when the client is requesting access to the protected 1307 resources under its control, or those of another resource owner which 1308 has been previously arranged with the authorization server (the 1309 method of which is beyond the scope of this specification). 1311 +---------+ +---------------+ 1312 | | | | 1313 | |>--(A)--- Client Credentials ---->| Authorization | 1314 | Client | | Server | 1315 | |<--(B)---- Access Token ---------<| | 1316 | | (w/ Optional Refresh Token) | | 1317 +---------+ +---------------+ 1319 Figure 6: Client Credentials Flow 1321 The flow illustrated in Figure 6 includes the following steps: 1323 (A) The client requests an access token from the token endpoint by 1324 authenticating using its client credentials. 1325 (B) The authorization server validates the client credentials and 1326 issues an access token. 1328 4.4.1. Authorization Request and Response 1330 Since the client credentials are used as the authorization grant, no 1331 additional authorization request is needed as the client is already 1332 in the possession of its client credentials. 1334 4.4.2. Access Token Request 1336 The client makes a request to the token endpoint by adding the 1337 following parameters using the "application/x-www-form-urlencoded" 1338 format in the HTTP request entity-body: 1340 grant_type 1341 REQUIRED. Value MUST be set to "client_credentials". 1342 client_id 1343 REQUIRED. The client identifier as described in Section 3. 1344 scope 1345 OPTIONAL. The scope of the access request expressed as a list 1346 of space-delimited, case sensitive strings. The value is 1347 defined by the authorization server. If the value contains 1348 multiple space-delimited strings, their order does not matter, 1349 and each string adds an additional access range to the 1350 requested scope. 1352 The client includes its authentication credentials as described in 1353 Section 3 1355 For example, the client makes the following HTTP request using 1356 transport-layer security (extra line breaks are for display purposes 1357 only): 1359 POST /token HTTP/1.1 1360 Host: server.example.com 1361 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW 1362 Content-Type: application/x-www-form-urlencoded 1364 grant_type=client_credentials&client_id=s6BhdRkqt3 1366 The authorization server MUST validate the client credentials. 1368 4.4.3. Access Token Response 1370 If the access token request is valid and authorized, the 1371 authorization server issues an access token and optional refresh 1372 token as described in Section 5.1. If the request failed client 1373 authentication or is invalid, the authorization server returns an 1374 error response as described in Section 5.2. 1376 An example successful response: 1378 HTTP/1.1 200 OK 1379 Content-Type: application/json 1380 Cache-Control: no-store 1382 { 1383 "access_token":"SlAV32hkKG", 1384 "token_type":"example", 1385 "expires_in":3600, 1386 "refresh_token":"8xLOxBtZp8", 1387 "example_parameter":"example_value" 1388 } 1390 4.5. Extensions 1392 The client uses an extension grant type by specifying the grant type 1393 using an absolute URI (defined by the authorization server) as the 1394 value of the "grant_type" parameter of the token endpoint, and by 1395 adding any additional parameters necessary. 1397 For example, to request an access token using a SAML 2.0 assertion 1398 grant type as defined by [I-D.ietf-oauth-saml2-bearer], the client 1399 makes the following HTTP request using transport-layer security (line 1400 breaks are for display purposes only): 1402 POST /token HTTP/1.1 1403 Host: server.example.com 1404 Content-Type: application/x-www-form-urlencoded 1406 grant_type=http%3A%2F%2Foauth.net%2Fgrant_type%2Fassertion%2F 1407 saml%2F2.0%2Fbearer&assertion=PEFzc2VydGlvbiBJc3N1ZUluc3RhbnQ 1408 [...omitted for brevity...]V0aG5TdGF0ZW1lbnQ-PC9Bc3NlcnRpb24- 1410 If the access token request is valid and authorized, the 1411 authorization server issues an access token and optional refresh 1412 token as described in Section 5.1. If the request failed client 1413 authentication or is invalid, the authorization server returns an 1414 error response as described in Section 5.2. 1416 5. Issuing an Access Token 1418 If the access token request is valid and authorized, the 1419 authorization server issues an access token and optional refresh 1420 token as described in Section 5.1. If the request failed client 1421 authentication or is invalid, the authorization server returns an 1422 error response as described in Section 5.2. 1424 5.1. Successful Response 1426 The authorization server issues an access token and optional refresh 1427 token, and constructs the response by adding the following parameters 1428 to the entity body of the HTTP response with a 200 (OK) status code: 1430 access_token 1431 REQUIRED. The access token issued by the authorization server. 1432 token_type 1433 REQUIRED. The type of the token issued as described in 1434 Section 7.1. Value is case insensitive. 1435 expires_in 1436 OPTIONAL. The duration in seconds of the access token 1437 lifetime. For example, the value "3600" denotes that the 1438 access token will expire in one hour from the time the response 1439 was generated. 1440 refresh_token 1441 OPTIONAL. The refresh token which can be used to obtain new 1442 access tokens using the same authorization grant as described 1443 in Section 6. 1444 scope 1445 OPTIONAL. The scope of the access request expressed as a list 1446 of space-delimited, case sensitive strings. The value is 1447 defined by the authorization server. If the value contains 1448 multiple space-delimited strings, their order does not matter, 1449 and each string adds an additional access range to the 1450 requested scope. The authorization server SHOULD include the 1451 parameter if the requested scope is different from the one 1452 requested by the client. 1454 The parameters are included in the entity body of the HTTP response 1455 using the "application/json" media type as defined by [RFC4627]. The 1456 parameters are serialized into a JSON structure by adding each 1457 parameter at the highest structure level. Parameter names and string 1458 values are included as JSON strings. Numerical values are included 1459 as JSON numbers. 1461 The authorization server MUST include the HTTP "Cache-Control" 1462 response header field [RFC2616] with a value of "no-store" in any 1463 response containing tokens, secrets, or other sensitive information. 1465 For example: 1467 HTTP/1.1 200 OK 1468 Content-Type: application/json 1469 Cache-Control: no-store 1471 { 1472 "access_token":"SlAV32hkKG", 1473 "token_type":"example", 1474 "expires_in":3600, 1475 "refresh_token":"8xLOxBtZp8", 1476 "example_parameter":"example_value" 1477 } 1479 The client SHOULD ignore unrecognized response parameters. The sizes 1480 of tokens and other values received from the authorization server are 1481 left undefined. The client should avoid making assumptions about 1482 value sizes. The authorization server should document the size of 1483 any value it issues. 1485 5.2. Error Response 1487 The authorization server responds with an HTTP 400 (Bad Request) 1488 status code and includes the following parameters with the response: 1490 error 1491 REQUIRED. A single error code from the following: 1492 invalid_request 1493 The request is missing a required parameter, includes an 1494 unsupported parameter or parameter value, repeats a 1495 parameter, includes multiple credentials, utilizes more 1496 than one mechanism for authenticating the client, or is 1497 otherwise malformed. 1498 invalid_client 1499 Client authentication failed (e.g. unknown client, no 1500 client credentials included, multiple client credentials 1501 included, or unsupported credentials type). The 1502 authorization server MAY return an HTTP 401 1503 (Unauthorized) status code to indicate which HTTP 1504 authentication schemes are supported. If the client 1505 attempted to authenticate via the "Authorization" request 1506 header field, the authorization server MUST respond with 1507 an HTTP 401 (Unauthorized) status code, and include the 1508 "WWW-Authenticate" response header field matching the 1509 authentication scheme used by the client. 1510 invalid_grant 1511 The provided authorization grant is invalid, expired, 1512 revoked, does not match the redirection URI used in the 1513 authorization request, or was issued to another client. 1514 unauthorized_client 1515 The authenticated client is not authorized to use this 1516 authorization grant type. 1517 unsupported_grant_type 1518 The authorization grant type is not supported by the 1519 authorization server. 1520 invalid_scope 1521 The requested scope is invalid, unknown, malformed, or 1522 exceeds the scope granted by the resource owner. 1523 error_description 1524 OPTIONAL. A human-readable text providing additional 1525 information, used to assist in the understanding and resolution 1526 of the error occurred. [[ add language and encoding information 1527 ]] 1528 error_uri 1529 OPTIONAL. A URI identifying a human-readable web page with 1530 information about the error, used to provide the resource owner 1531 with additional information about the error. 1533 The parameters are included in the entity body of the HTTP response 1534 using the "application/json" media type as defined by [RFC4627]. The 1535 parameters are serialized into a JSON structure by adding each 1536 parameter at the highest structure level. Parameter names and string 1537 values are included as JSON strings. Numerical values are included 1538 as JSON numbers. 1540 For example: 1542 HTTP/1.1 400 Bad Request 1543 Content-Type: application/json 1544 Cache-Control: no-store 1546 { 1547 "error":"invalid_request" 1548 } 1550 If the authorization server encounters an error condition other than 1551 the 400 (Bad Request) and 401 (Unauthorized) responses described 1552 above (e.g. the service is temporarily unavailable), the 1553 authorization server SHOULD include an error response in the entity 1554 body, and set the "error" parameter value to the numerical HTTP 1555 status code returned. 1557 For example: 1559 HTTP/1.1 503 Service Unavailable 1560 Content-Type: application/json 1562 { 1563 "error":"503" 1564 } 1566 6. Refreshing an Access Token 1568 If the authorization server issued a refresh token to the client, the 1569 client makes a refresh request to the token endpoint by adding the 1570 following parameters using the "application/x-www-form-urlencoded" 1571 format in the HTTP request entity-body: 1573 grant_type 1574 REQUIRED. Value MUST be set to "refresh_token". 1575 client_id 1576 REQUIRED. The client identifier as described in Section 3. 1577 refresh_token 1578 REQUIRED. The refresh token issued to the client. 1579 scope 1580 OPTIONAL. The scope of the access request expressed as a list 1581 of space-delimited, case sensitive strings. The value is 1582 defined by the authorization server. If the value contains 1583 multiple space-delimited strings, their order does not matter, 1584 and each string adds an additional access range to the 1585 requested scope. The requested scope MUST be equal or lesser 1586 than the scope originally granted by the resource owner, and if 1587 omitted is treated as equal to the scope originally granted by 1588 the resource owner. 1590 The client includes its authentication credentials as described in 1591 Section 3. 1593 For example, the client makes the following HTTP request using 1594 transport-layer security (extra line breaks are for display purposes 1595 only): 1597 POST /token HTTP/1.1 1598 Host: server.example.com 1599 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW 1600 Content-Type: application/x-www-form-urlencoded 1602 grant_type=refresh_token&client_id=s6BhdRkqt3& 1603 refresh_token=n4E9O119d 1605 The authorization server MUST validate the client credentials, ensure 1606 that the refresh token was issued to the authenticated client, 1607 validate the refresh token, and verify that the resource owner's 1608 authorization is still valid. If valid and authorized, the 1609 authorization server issues an access token as described in 1610 Section 5.1. If the request failed verification or is invalid, the 1611 authorization server returns an error response as described in 1612 Section 5.2. 1614 The authorization server MAY issue a new refresh token, in which 1615 case, the client MUST discard the old refresh token and replace it 1616 with the new refresh token. 1618 7. Accessing Protected Resources 1620 The client accesses protected resources by presenting the access 1621 token to the resource server. The resource server MUST validate the 1622 access token and ensure it has not expired and that its scope covers 1623 the requested resource. The methods used by the resource server to 1624 validate the access token (as well as any error responses) are beyond 1625 the scope of this specification, but generally involve an interaction 1626 or coordination between the resource server and the authorization 1627 server. 1629 The method in which the client utilized the access token to 1630 authenticate with the resource server depends on the type of access 1631 token issued by the authorization server. Typically, it involves 1632 using the HTTP "Authorization" request header field [RFC2617] with an 1633 authentication scheme defined by the access token type specification. 1635 7.1. Access Token Types 1637 The access token type provides the client with the information 1638 required to successfully utilize the access token to make a protected 1639 resource request (along with type-specific attributes). The client 1640 MUST NOT use an access token if it does not understand the token 1641 type. 1643 For example, the "bearer" token type defined in 1644 [I-D.ietf-oauth-v2-bearer] is utilized by simply including the access 1645 token string in the request: 1647 GET /resource/1 HTTP/1.1 1648 Host: example.com 1649 Authorization: Bearer 7Fjfp0ZBr1KtDRbnfVdmIw 1651 while the "mac" token type defined in [I-D.ietf-oauth-v2-http-mac] is 1652 utilized by issuing a MAC key together with the access token which is 1653 used to sign certain components of the HTTP requests: 1655 GET /resource/1 HTTP/1.1 1656 Host: example.com 1657 Authorization: MAC id="h480djs93hd8", 1658 nonce="274312:dj83hs9s", 1659 mac="kDZvddkndxvhGRXZhvuDjEWhGeE=" 1661 The above examples are provided for illustration purposes only. 1662 Developers are advised to consult the [I-D.ietf-oauth-v2-bearer] and 1663 [I-D.ietf-oauth-v2-http-mac] specifications before use. 1665 Each access token type definition specifies the additional attributes 1666 (if any) sent to the client together with the "access_token" response 1667 parameter. It also defines the HTTP authentication method used to 1668 include the access token when making a protected resource request. 1670 8. Extensibility 1672 8.1. Defining Access Token Types 1674 Access token types can be defined in one of two ways: registered in 1675 the access token type registry (following the procedures in 1676 Section 11.1), or use a unique absolute URI as its name. 1678 Types utilizing a URI name SHOULD be limited to vendor-specific 1679 implementations that are not commonly applicable, and are specific to 1680 the implementation details of the resource server where they are 1681 used. 1683 All other types MUST be registered. Type names MUST conform to the 1684 type-name ABNF. If the type definition includes a new HTTP 1685 authentication scheme, the type name SHOULD be identical to the HTTP 1686 authentication scheme name (as defined by [RFC2617]). 1688 type-name = 1*name-char 1689 name-char = "-" / "." / "_" / DIGIT / ALPHA 1691 8.2. Defining New Endpoint Parameters 1693 New request or response parameters for use with the authorization 1694 endpoint or the token endpoint are defined and registered in the 1695 parameters registry following the procedure in Section 11.2. 1697 Parameter names MUST conform to the param-name ABNF and parameter 1698 values syntax MUST be well-defined (e.g., using ABNF, or a reference 1699 to the syntax of an existing parameter). 1701 param-name = 1*name-char 1702 name-char = "-" / "." / "_" / DIGIT / ALPHA 1704 Unregistered vendor-specific parameter extensions that are not 1705 commonly applicable, and are specific to the implementation details 1706 of the authorization server where they are used SHOULD utilize a 1707 vendor-specific prefix that is not likely to conflict with other 1708 registered values (e.g. begin with 'companyname_'). 1710 8.3. Defining New Authorization Grant Types 1712 New authorization grant types can be defined by assigning them a 1713 unique absolute URI for use with the "grant_type" parameter. If the 1714 extension grant type requires additional token endpoint parameters, 1715 they MUST be registered in the OAuth parameters registry as described 1716 by Section 11.2. 1718 8.4. Defining Additional Error Codes 1720 In cases where protocol extensions (i.e. access token types, 1721 extension parameters, or extension grant types) require additional 1722 error codes to be used with the authorization code grant error 1723 response (Section 4.1.2.1), the implicit grant error response 1724 (Section 4.2.2.1), or the token error response (Section 5.2), such 1725 error codes MAY be defined. 1727 Extension error codes MUST be registered (following the procedures in 1728 Section 11.3) if the extension they are used in conjunction with is a 1729 registered access token type, a registered endpoint parameter, or an 1730 extension grant type. Error codes used with unregistered extensions 1731 MAY be registered. 1733 Error codes MUST conform to the error-code ABNF, and SHOULD be 1734 prefixed by an identifying name when possible. For example, an error 1735 identifying an invalid value set to the extension parameter "example" 1736 should be named "example_invalid". 1738 error-code = ALPHA *error-char 1739 error-char = "-" / "." / "_" / DIGIT / ALPHA 1741 9. Native Applications 1743 [[ Pending consensus ]] 1745 A native application is a client which is installed and executes on 1746 the end-user's device (i.e. desktop application, native mobile 1747 application). Native applications are often capable of interacting 1748 with (or embedding) a user-agent but are limited in how such 1749 interactions affects their overall end-user experience. In many 1750 cases, native applications are incapable of receiving redirection 1751 requests from the authorization server (e.g. due to firewall rules, 1752 operating system restrictions). 1754 Native applications can utilize OAuth in different ways, based on 1755 their requirements and desired end-user experience: 1757 o Use the authorization code grant type flow described in 1758 Section 4.1 by launching an external user-agent. The native 1759 application can capture the response by providing a redirection 1760 URI identifying a local (non-network) resource (registered with 1761 the operating system to invoke the native application as handler), 1762 or by providing a redirection URI identifying a server-hosted 1763 resource under the native application's control, which in turn 1764 makes the response available to the native application (e.g. using 1765 the user-agent window title or other locations accessible from 1766 outside the user-agent). 1768 o Use the authorization code grant type flow described in 1769 Section 4.1 by embedding a user-agent. The native application 1770 obtains the response by directly communicating with the embedded 1771 user-agent. Embedded user-agents are discouraged as they 1772 typically provide a less consistent user experience and do not 1773 enable the end-user to verify the authorization server's 1774 authenticity. 1776 Native applications SHOULD use the authorization code grant type flow 1777 without client password credentials (due to their inability to keep 1778 the credentials confidential) to obtain short-lived access tokens, 1779 and use refresh tokens to maintain access. 1781 When choosing between launching an external user-agent and an 1782 embedding a user-agent, native application developers should consider 1783 the following: 1785 o External user-agents may improve completion rate as the end-user 1786 may already have an active session with the authorization server 1787 removing the need to re-authenticate, and provide a familiar user- 1788 agent user experience. The end-user may also rely on extensions 1789 or add-ons to assist with authentication (e.g. password managers 1790 or 2-factor device reader). 1791 o Embedded user-agents often offer a better end-user flow, as they 1792 remove the need to switch context and open new windows but also 1793 may provide less familiar features than the external user-agent. 1794 o Embedded user-agents pose a security challenge because end-users 1795 are authenticating in an unidentified window without access to the 1796 visual protections offered by many user-agents. Embedded user- 1797 agents educate end-user to trust unidentified requests for 1798 authentication (making phishing attacks easier to execute). 1800 10. Security Considerations 1802 As a flexible and extensible framework, OAuth's security 1803 considerations depend on many factors. The following sections 1804 provide implementers with security guidelines focused on three common 1805 client types: 1807 Web Application 1808 A web application is a client running on a web server. End-users 1809 access the client via an HTML user interface rendered in a user- 1810 agent on the end-user's device. The client credentials as well as 1811 any access token issued to the client are stored on the web server 1812 and are not exposed to or accessible by the end-user. 1814 User-Agent-based Application 1815 A user-agent-based application is a client in which the client 1816 code is downloaded from a web server and executes within a user- 1817 agent on the end-user's device. The OAuth protocol data and 1818 credentials are accessible to the end-user. Since such 1819 applications directly reside within the user-agent, they can make 1820 seamless use of the user-agent capabilities in the end-user 1821 authorization process. 1822 Native Application 1823 A native application is a client which is installed and executes 1824 on the end-user's device. The OAuth protocol data and credentials 1825 are accessible to the end-user. It is assumed that such an 1826 application can protect dynamically issued credentials, such as 1827 refresh tokens, from eavesdropping by other applications residing 1828 on the same device. 1830 A comprehensive OAuth security model and analysis, as well as 1831 background for the protocol design is provided in 1832 [I-D.lodderstedt-oauth-security]. 1834 10.1. Client Authentication 1836 The authorization server issues client credentials to web 1837 applications for the purpose of authenticating them. The 1838 authorization server is encouraged to consider using stronger client 1839 authentication means than a client password. Application developers 1840 MUST ensure confidentiality of client passwords and other 1841 credentials. 1843 The authorization server MUST NOT issue client passwords or other 1844 credentials to native or user-agent-based applications for the 1845 purpose of client authentication. The authorization server MAY issue 1846 a client password or other credentials for a specific installation of 1847 a native application on a specific device. 1849 10.2. Client Impersonation 1851 Given the inability of some clients to keep their client credentials 1852 confidential, a malicious client can impersonate another client and 1853 obtain access to protected resources. The authorization server MUST 1854 authenticate the client whenever possible. If the authorization 1855 server cannot authenticate the a client due to the client's 1856 limitations, the authorization server should utilize other means to 1857 protect resource owners from such malicious clients, including but 1858 not limited to engaging the end-user to assist in identifying the 1859 client and its source. 1861 The authorization server SHOULD enforce explicit end-user 1862 authentication, or prompt the end-user to authorize access again, 1863 providing the end-user with information about the client, scope, and 1864 duration of the authorization. It is up to the end-user to review 1865 the information in the context of the current client, and authorize 1866 the request. 1868 The authorization server SHOULD NOT automatically, without active 1869 end-user interaction, process repeated authorization requests without 1870 authenticating the client or relying on other measures to ensure the 1871 repeated request comes from a valid client and not an impersonator. 1873 The authorization server SHOULD require the client to pre-register 1874 its redirection URI and validate the value of the "redirect_uri" 1875 against the pre-registered value. The client MUST NOT serve an open 1876 redirector resource which can be used by an attacker to construct an 1877 URI that will pass the authorization server's redirection URI 1878 matching rules, and will redirect the end-user's user-agent to the 1879 attacker's server. 1881 The authorization server SHOULD issue access tokens with limited 1882 scope and duration to clients incapable of authenticating. 1884 10.3. Access Token Credentials 1886 Access token credentials MUST be kept confidential in transit and 1887 storage, and shared only among the authorization server, the resource 1888 servers the credentials are valid for, and the client to whom the 1889 credentials were issued. 1891 When using the implicit grant type, the access token credentials are 1892 transmitted in the URI fragment, which can expose the credentials to 1893 unauthorized parties. 1895 The authorization server MUST ensure that access token credentials 1896 cannot be generated, modified, or guessed to produce valid access 1897 token credentials. 1899 The client SHOULD request access token credentials with the minimal 1900 scope and duration necessary. The authorization server SHOULD take 1901 the client identity into account when choosing to honor the requested 1902 scope, and MAY issue credentials with a lesser scope than requested. 1904 10.4. Refresh Tokens 1906 Authorization servers MAY issue refresh tokens to web and native 1907 applications. 1909 Refresh tokens MUST be kept confidential in transit and storage, and 1910 shared only among the authorization server and the client to whom the 1911 refresh tokens were issued. The authorization server MUST maintain 1912 the link between a refresh token and the client to whom it was 1913 issued. 1915 The authorization server MUST verify the link between the refresh 1916 token and client identity whenever the client's identity can be 1917 authenticated. When client authentication is not possible, the 1918 authorization server SHOULD deploy other means to detect refresh 1919 token abuse. 1921 The authorization server MUST ensure that refresh tokens cannot be 1922 generated, modified, or guessed to produce valid refresh tokens. 1924 10.5. Request Confidentiality 1926 Access token credentials, refresh tokens, resource owner passwords, 1927 and client secrets MUST NOT be transmitted in the clear. 1928 Authorization codes SHOULD NOT be transmitted in the clear. 1930 10.6. Endpoints Authenticity 1932 In order to prevent man-in-the-middle and phishing attacks, the 1933 authorization server MUST implement and require TLS with server-side 1934 authentication in all exchanges. The client MUST verify the 1935 authorization server's TLS certificate, as well as the respective 1936 certificate chain. 1938 10.7. Credentials Guessing Attacks 1940 The authorization server MUST prevent attackers from guessing access 1941 tokens, authorization codes, refresh tokens, resource owner 1942 passwords, and client secrets. 1944 When generating tokens and other secrets not intended for direct 1945 human utilization, the authorization server MUST use a reasonable 1946 level of entropy in order to mitigate the risk of guessing attacks. 1947 When creating secrets intended for human usage, the authorization 1948 server MUST utilize other means to protect those secrets. 1950 10.8. Phishing Attacks 1952 Native applications SHOULD use external browsers instead of embedding 1953 browsers within the application when requesting end-user 1954 authorization. External browsers offer a familiar user experience 1955 and a trusted environment in which end-users can confirm the 1956 authenticity of the authorization server. 1958 To reduce the risk of phishing attacks, the authorization servers 1959 MUST utilize TLS to allow user-agents to validate the authorization 1960 server's identity. Service providers should educate their end-users 1961 about the risks of phishing attacks and how they can verify the 1962 authorization server's identity. 1964 10.9. Authorization Codes 1966 The transmission of authorization codes SHOULD be made over a secure 1967 channel, and the client SHOULD implement TLS for use with its 1968 redirection URI if the URI identifies a network resource. 1969 Authorization codes MUST be kept confidential. Since authorization 1970 codes are transmitted via user-agent redirections, they could 1971 potentially be disclosed through user-agent history and HTTP referrer 1972 headers. 1974 Authorization codes operate as plaintext bearer credentials, used to 1975 verify that the end-user who granted authorization at the 1976 authorization server, is the same end-user returning to the client to 1977 complete the process. Therefore, if the client relies on the 1978 authorization code for its own end-user authentication, the client 1979 redirection endpoint MUST require TLS. 1981 Authorization codes SHOULD be short lived and MUST be single use. If 1982 the authorization server observes multiple attempts to exchange an 1983 authorization code for an access token, the authorization server 1984 SHOULD revoke all access tokens already granted based on the 1985 compromised authorization code. 1987 If the client can be authenticated, the authorization servers MUST 1988 authenticate the client and ensure that the authorization code was 1989 issued to the same client. 1991 10.10. Session Fixation 1993 Session fixation attacks leverage the authorization code grant type, 1994 by tricking an end-user to authorize access to a legitimate client, 1995 but to a client account under the control of the attacker. The only 1996 difference between a valid flow and the attack flow is in how the 1997 victim reached the authorization server to grant access. Once at the 1998 authorization server, the victim is prompted with a normal, valid 1999 request on behalf of a legitimate and familiar client. The attacker 2000 then uses the victim's authorization to gain access to the 2001 information authorized by the victim. 2003 In order to prevent such an attack, authorization servers MUST ensure 2004 that the redirection URI used to obtain the authorization code, is 2005 the same as the redirection URI provided when exchanging the 2006 authorization code for an access token. The authorization server 2007 SHOULD require the client to pre-register their redirection URI and 2008 if provided, MUST validate the redirection URI received in the 2009 authorization request against the pre-registered value. 2011 10.11. Redirection URI Validation 2013 [[ Add specific recommendations about redirection validation and 2014 matching ]] 2016 10.12. Resource Owner Password Credentials 2018 The resource owner password credentials grant type is often used for 2019 legacy or migration reasons. It reduces the overall risk of storing 2020 username and password in the client, but does not eliminate the need 2021 to expose highly privileged credentials to the client. 2023 This grant type carries a higher risk than the other grant types 2024 because it maintains the password anti-pattern OAuth seeks to avoid. 2025 The client could abuse the password or the password could 2026 unintentionally be disclosed to an attacker (e.g. via log files or 2027 other records kept by the client). 2029 Additionally, because the resource owner does not have control over 2030 the authorization process (the resource owner involvement ends when 2031 it hands over its credentials to the client), the client can obtain 2032 access tokens with a broader scope and longer duration than desired 2033 by the resource owner. The authorization server SHOULD restrict the 2034 scope and duration of access tokens issued via this grant type. 2036 The authorization server and client SHOULD minimize use of this grant 2037 type and utilize other grant types whenever possible. 2039 10.13. XSRF/CSRF Prevention 2041 [[ Add text with reference to the 'state' parameter ]] 2043 11. IANA Considerations 2045 11.1. The OAuth Access Token Type Registry 2047 This specification establishes the OAuth access token type registry. 2049 Access token types are registered on the advice of one or more 2050 Designated Experts (appointed by the IESG or their delegate), with a 2051 Specification Required (using terminology from [RFC5226]). However, 2052 to allow for the allocation of values prior to publication, the 2053 Designated Expert(s) may approve registration once they are satisfied 2054 that such a specification will be published. 2056 Registration requests should be sent to the [TBD]@ietf.org mailing 2057 list for review and comment, with an appropriate subject (e.g., 2058 "Request for access toke type: example"). [[ Note to RFC-EDITOR: The 2059 name of the mailing list should be determined in consultation with 2060 the IESG and IANA. Suggested name: oauth-ext-review. ]] 2062 Within at most 14 days of the request, the Designated Expert(s) will 2063 either approve or deny the registration request, communicating this 2064 decision to the review list and IANA. Denials should include an 2065 explanation and, if applicable, suggestions as to how to make the 2066 request successful. 2068 Decisions (or lack thereof) made by the Designated Expert can be 2069 first appealed to Application Area Directors (contactable using 2070 app-ads@tools.ietf.org email address or directly by looking up their 2071 email addresses on http://www.iesg.org/ website) and, if the 2072 appellant is not satisfied with the response, to the full IESG (using 2073 the iesg@iesg.org mailing list). 2075 IANA should only accept registry updates from the Designated 2076 Expert(s), and should direct all requests for registration to the 2077 review mailing list. 2079 11.1.1. Registration Template 2081 Type name: 2082 The name requested (e.g., "example"). 2083 Additional Token Endpoint Response Parameters: 2084 Additional response parameters returned together with the 2085 "access_token" parameter. New parameters MUST be separately 2086 registered in the OAuth parameters registry as described by 2087 Section 11.2. 2088 HTTP Authentication Scheme(s): 2089 The HTTP authentication scheme name(s), if any, used to 2090 authenticate protected resources requests using access token of 2091 this type. 2092 Change controller: 2093 For standards-track RFCs, state "IETF". For others, give the name 2094 of the responsible party. Other details (e.g., postal address, 2095 e-mail address, home page URI) may also be included. 2096 Specification document(s): 2097 Reference to document that specifies the parameter, preferably 2098 including a URI that can be used to retrieve a copy of the 2099 document. An indication of the relevant sections may also be 2100 included, but is not required. 2102 11.2. The OAuth Parameters Registry 2104 This specification establishes the OAuth parameters registry. 2106 Additional parameters for inclusion in the authorization endpoint 2107 request, the authorization endpoint response, the token endpoint 2108 request, or the token endpoint response, are registered on the advice 2109 of one or more Designated Experts (appointed by the IESG or their 2110 delegate), with a Specification Required (using terminology from 2111 [RFC5226]). However, to allow for the allocation of values prior to 2112 publication, the Designated Expert(s) may approve registration once 2113 they are satisfied that such a specification will be published. 2115 Registration requests should be sent to the [TBD]@ietf.org mailing 2116 list for review and comment, with an appropriate subject (e.g., 2117 "Request for parameter: example"). [[ Note to RFC-EDITOR: The name of 2118 the mailing list should be determined in consultation with the IESG 2119 and IANA. Suggested name: oauth-ext-review. ]] 2121 Within at most 14 days of the request, the Designated Expert(s) will 2122 either approve or deny the registration request, communicating this 2123 decision to the review list and IANA. Denials should include an 2124 explanation and, if applicable, suggestions as to how to make the 2125 request successful. 2127 Decisions (or lack thereof) made by the Designated Expert can be 2128 first appealed to Application Area Directors (contactable using 2129 app-ads@tools.ietf.org email address or directly by looking up their 2130 email addresses on http://www.iesg.org/ website) and, if the 2131 appellant is not satisfied with the response, to the full IESG (using 2132 the iesg@iesg.org mailing list). 2134 IANA should only accept registry updates from the Designated 2135 Expert(s), and should direct all requests for registration to the 2136 review mailing list. 2138 11.2.1. Registration Template 2140 Parameter name: 2141 The name requested (e.g., "example"). 2142 Parameter usage location: 2143 The location(s) where parameter can be used. The possible 2144 locations are: authorization request, authorization response, 2145 token request, or token response. 2147 Change controller: 2148 For standards-track RFCs, state "IETF". For others, give the name 2149 of the responsible party. Other details (e.g., postal address, 2150 e-mail address, home page URI) may also be included. 2151 Specification document(s): 2152 Reference to document that specifies the parameter, preferably 2153 including a URI that can be used to retrieve a copy of the 2154 document. An indication of the relevant sections may also be 2155 included, but is not required. 2157 11.2.2. Initial Registry Contents 2159 The OAuth Parameters Registry's initial contents are: 2161 o Parameter name: client_id 2162 o Parameter usage location: authorization request, token request 2163 o Change controller: IETF 2164 o Specification document(s): [[ this document ]] 2166 o Parameter name: client_secret 2167 o Parameter usage location: token request 2168 o Change controller: IETF 2169 o Specification document(s): [[ this document ]] 2171 o Parameter name: response_type 2172 o Parameter usage location: authorization request 2173 o Change controller: IETF 2174 o Specification document(s): [[ this document ]] 2176 o Parameter name: redirect_uri 2177 o Parameter usage location: authorization request, token request 2178 o Change controller: IETF 2179 o Specification document(s): [[ this document ]] 2181 o Parameter name: scope 2182 o Parameter usage location: authorization request, authorization 2183 response, token request, token response 2184 o Change controller: IETF 2185 o Specification document(s): [[ this document ]] 2187 o Parameter name: state 2188 o Parameter usage location: authorization request, authorization 2189 response 2190 o Change controller: IETF 2191 o Specification document(s): [[ this document ]] 2192 o Parameter name: code 2193 o Parameter usage location: authorization response, token request 2194 o Change controller: IETF 2195 o Specification document(s): [[ this document ]] 2197 o Parameter name: error_description 2198 o Parameter usage location: authorization response, token response 2199 o Change controller: IETF 2200 o Specification document(s): [[ this document ]] 2202 o Parameter name: error_uri 2203 o Parameter usage location: authorization response, token response 2204 o Change controller: IETF 2205 o Specification document(s): [[ this document ]] 2207 o Parameter name: grant_type 2208 o Parameter usage location: token request 2209 o Change controller: IETF 2210 o Specification document(s): [[ this document ]] 2212 o Parameter name: access_token 2213 o Parameter usage location: authorization response, token response 2214 o Change controller: IETF 2215 o Specification document(s): [[ this document ]] 2217 o Parameter name: token_type 2218 o Parameter usage location: authorization response, token response 2219 o Change controller: IETF 2220 o Specification document(s): [[ this document ]] 2222 o Parameter name: expires_in 2223 o Parameter usage location: authorization response, token response 2224 o Change controller: IETF 2225 o Specification document(s): [[ this document ]] 2227 o Parameter name: username 2228 o Parameter usage location: token request 2229 o Change controller: IETF 2230 o Specification document(s): [[ this document ]] 2232 o Parameter name: password 2233 o Parameter usage location: token request 2234 o Change controller: IETF 2235 o Specification document(s): [[ this document ]] 2237 o Parameter name: refresh_token 2238 o Parameter usage location: token request, token response 2239 o Change controller: IETF 2240 o Specification document(s): [[ this document ]] 2242 11.3. The OAuth Extensions Error Registry 2244 This specification establishes the OAuth extensions error registry. 2246 Additional error codes used together with other protocol extensions 2247 (i.e. extension grant types, access token types, or extension 2248 parameters) are registered on the advice of one or more Designated 2249 Experts (appointed by the IESG or their delegate), with a 2250 Specification Required (using terminology from [RFC5226]). However, 2251 to allow for the allocation of values prior to publication, the 2252 Designated Expert(s) may approve registration once they are satisfied 2253 that such a specification will be published. 2255 Registration requests should be sent to the [TBD]@ietf.org mailing 2256 list for review and comment, with an appropriate subject (e.g., 2257 "Request for error code: example"). [[ Note to RFC-EDITOR: The name 2258 of the mailing list should be determined in consultation with the 2259 IESG and IANA. Suggested name: oauth-ext-review. ]] 2261 Within at most 14 days of the request, the Designated Expert(s) will 2262 either approve or deny the registration request, communicating this 2263 decision to the review list and IANA. Denials should include an 2264 explanation and, if applicable, suggestions as to how to make the 2265 request successful. 2267 Decisions (or lack thereof) made by the Designated Expert can be 2268 first appealed to Application Area Directors (contactable using 2269 app-ads@tools.ietf.org email address or directly by looking up their 2270 email addresses on http://www.iesg.org/ website) and, if the 2271 appellant is not satisfied with the response, to the full IESG (using 2272 the iesg@iesg.org mailing list). 2274 IANA should only accept registry updates from the Designated 2275 Expert(s), and should direct all requests for registration to the 2276 review mailing list. 2278 11.3.1. Registration Template 2280 Error name: 2281 The name requested (e.g., "example"). 2283 Error usage location: 2284 The location(s) where the error can be used. The possible 2285 locations are: authorization code grant error response 2286 (Section 4.1.2.1), implicit grant error response 2287 (Section 4.2.2.1), or token error response (Section 5.2). 2288 Related protocol extension: 2289 The name of the extension grant type, access token type, or 2290 extension parameter, the error code is used in conjunction with. 2291 Change controller: 2292 For standards-track RFCs, state "IETF". For others, give the name 2293 of the responsible party. Other details (e.g., postal address, 2294 e-mail address, home page URI) may also be included. 2295 Specification document(s): 2296 Reference to document that specifies the error code, preferably 2297 including a URI that can be used to retrieve a copy of the 2298 document. An indication of the relevant sections may also be 2299 included, but is not required. 2301 12. Acknowledgements 2303 The initial OAuth 2.0 protocol specification was edited by David 2304 Recordon, based on two previous publications: the OAuth 1.0 community 2305 specification [RFC5849], and OAuth WRAP (OAuth Web Resource 2306 Authorization Profiles) [I-D.draft-hardt-oauth-01]. The Security 2307 Considerations section was drafted by Torsten Lodderstedt, Mark 2308 McGloin, Phil Hunt, and Anthony Nadalin. 2310 The OAuth 1.0 community specification was edited by Eran Hammer-Lahav 2311 and authored by Mark Atwood, Dirk Balfanz, Darren Bounds, Richard M. 2312 Conlan, Blaine Cook, Leah Culver, Breno de Medeiros, Brian Eaton, 2313 Kellan Elliott-McCrea, Larry Halff, Eran Hammer-Lahav, Ben Laurie, 2314 Chris Messina, John Panzer, Sam Quigley, David Recordon, Eran 2315 Sandler, Jonathan Sergent, Todd Sieling, Brian Slesinsky, and Andy 2316 Smith. 2318 The OAuth WRAP specification was edited by Dick Hardt and authored by 2319 Brian Eaton, Yaron Goland, Dick Hardt, and Allen Tom. 2321 This specification is the work of the OAuth Working Group which 2322 includes dozens of active and dedicated participants. In particular, 2323 the following individuals contributed ideas, feedback, and wording 2324 which shaped and formed the final specification: 2326 Michael Adams, Andrew Arnott, Dirk Balfanz, Scott Cantor, Blaine 2327 Cook, Brian Campbell, Leah Culver, Bill de hOra, Brian Eaton, Brian 2328 Ellin, Igor Faynberg, George Fletcher, Tim Freeman, Evan Gilbert, 2329 Yaron Goland, Brent Goldman, Kristoffer Gronowski, Justin Hart, Craig 2330 Heath, Phil Hunt, Michael B. Jones, John Kemp, Mark Kent, Raffi 2331 Krikorian, Chasen Le Hara, Rasmus Lerdorf, Torsten Lodderstedt, Hui- 2332 Lan Lu, Paul Madsen, Alastair Mair, Eve Maler, James Manger, Mark 2333 McGloin, Laurence Miao, Chuck Mortimore, Justin Richer, Peter Saint- 2334 Andre, Nat Sakimura, Rob Sayre, Marius Scurtescu, Naitik Shah, Luke 2335 Shepard, Vlad Skvortsov, Justin Smith, Jeremy Suriel, Christian 2336 Stuebner, Paul Tarjan, Allen Tom, Franklin Tse, Nick Walker, Skylar 2337 Woodward. 2339 Appendix A. Editor's Notes 2341 While many people contributed to this specification throughout its 2342 long journey, the editor would like to acknowledge and thank a few 2343 individuals for their outstanding and invaluable efforts leading up 2344 to the publication of this specification. It is these individuals 2345 without whom this work would not have existed, or reached its 2346 successful conclusion. 2348 David Recordon for continuously being one of OAuth's most valuable 2349 assets, bringing pragmatism and urgency to the work, and helping 2350 shape it from its very beginning, as well as being one of the best 2351 collaborators I had the pleasure of working with. 2353 Mark Nottingham for introducing OAuth to the IETF and setting the 2354 community on this course. Lisa Dusseault for her support and 2355 guidance as the Application area director. Blaine Cook, Peter Saint- 2356 Andre, and Hannes Tschofenig for their work as working group chairs. 2358 James Manger for his creative ideas and always insightful feedback. 2359 Brian Campbell, Torsten Lodderstedt, Chuck Mortimore, Justin Richer, 2360 Marius Scurtescu, and Luke Shepard for their continued participation 2361 and valuable feedback. 2363 Special thanks goes to Mike Curtis and Yahoo! for their unconditional 2364 support of this work for over three years. 2366 13. References 2368 13.1. Normative References 2370 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2371 Requirement Levels", BCP 14, RFC 2119, March 1997. 2373 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 2374 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 2375 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 2377 [RFC2617] Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S., 2378 Leach, P., Luotonen, A., and L. Stewart, "HTTP 2379 Authentication: Basic and Digest Access Authentication", 2380 RFC 2617, June 1999. 2382 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 2383 Resource Identifier (URI): Generic Syntax", STD 66, 2384 RFC 3986, January 2005. 2386 [RFC4627] Crockford, D., "The application/json Media Type for 2387 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 2389 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 2390 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 2391 May 2008. 2393 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 2394 Specifications: ABNF", STD 68, RFC 5234, January 2008. 2396 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 2397 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 2399 [W3C.REC-html401-19991224] 2400 Hors, A., Jacobs, I., and D. Raggett, "HTML 4.01 2401 Specification", World Wide Web Consortium 2402 Recommendation REC-html401-19991224, December 1999, 2403 . 2405 13.2. Informative References 2407 [I-D.draft-hardt-oauth-01] 2408 Hardt, D., Ed., Tom, A., Eaton, B., and Y. Goland, "OAuth 2409 Web Resource Authorization Profiles", January 2010. 2411 [I-D.ietf-oauth-saml2-bearer] 2412 Campbell, B. and C. Mortimore, "SAML 2.0 Bearer Assertion 2413 Grant Type Profile for OAuth 2.0", 2414 draft-ietf-oauth-saml2-bearer-03 (work in progress), 2415 February 2011. 2417 [I-D.ietf-oauth-v2-bearer] 2418 Jones, M., Hardt, D., and D. Recordon, "The OAuth 2.0 2419 Protocol: Bearer Tokens", draft-ietf-oauth-v2-bearer-04 2420 (work in progress), March 2011. 2422 [I-D.ietf-oauth-v2-http-mac] 2423 Hammer-Lahav, E., Barth, A., and B. Adida, "HTTP 2424 Authentication: MAC Access Authentication", 2425 draft-ietf-oauth-v2-http-mac-00 (work in progress), 2426 May 2011. 2428 [I-D.lodderstedt-oauth-security] 2429 Lodderstedt, T., McGloin, M., and P. Hunt, "OAuth 2.0 2430 Threat Model and Security Considerations", 2431 draft-lodderstedt-oauth-security-01 (work in progress), 2432 March 2011. 2434 [OASIS.saml-core-2.0-os] 2435 Cantor, S., Kemp, J., Philpott, R., and E. Maler, 2436 "Assertions and Protocol for the OASIS Security Assertion 2437 Markup Language (SAML) V2.0", OASIS Standard saml-core- 2438 2.0-os, March 2005. 2440 [RFC5849] Hammer-Lahav, E., "The OAuth 1.0 Protocol", RFC 5849, 2441 April 2010. 2443 Authors' Addresses 2445 Eran Hammer-Lahav (editor) 2446 Yahoo! 2448 Email: eran@hueniverse.com 2449 URI: http://hueniverse.com 2451 David Recordon 2452 Facebook 2454 Email: dr@fb.com 2455 URI: http://www.davidrecordon.com/ 2457 Dick Hardt 2458 Microsoft 2460 Email: dick.hardt@gmail.com 2461 URI: http://dickhardt.org/