-
Notifications
You must be signed in to change notification settings - Fork 6
/
draft-ietf-oauth-v2.html
4767 lines (3926 loc) · 216 KB
/
draft-ietf-oauth-v2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en"><head><title>The OAuth 2.0 Authorization Protocol</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="The OAuth 2.0 Authorization Protocol">
<meta name="generator" content="xml2rfc v1.36 (http://xml.resource.org/)">
<style type='text/css'><!--
body {
font-family: verdana, charcoal, helvetica, arial, sans-serif;
font-size: small; color: #000; background-color: #FFF;
margin: 2em;
}
h1, h2, h3, h4, h5, h6 {
font-family: helvetica, monaco, "MS Sans Serif", arial, sans-serif;
font-weight: bold; font-style: normal;
}
h1 { color: #900; background-color: transparent; text-align: right; }
h3 { color: #333; background-color: transparent; }
td.RFCbug {
font-size: x-small; text-decoration: none;
width: 30px; height: 30px; padding-top: 2px;
text-align: justify; vertical-align: middle;
background-color: #000;
}
td.RFCbug span.RFC {
font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
font-weight: bold; color: #666;
}
td.RFCbug span.hotText {
font-family: charcoal, monaco, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
font-weight: normal; text-align: center; color: #FFF;
}
table.TOCbug { width: 30px; height: 15px; }
td.TOCbug {
text-align: center; width: 30px; height: 15px;
color: #FFF; background-color: #900;
}
td.TOCbug a {
font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, sans-serif;
font-weight: bold; font-size: x-small; text-decoration: none;
color: #FFF; background-color: transparent;
}
td.header {
font-family: arial, helvetica, sans-serif; font-size: x-small;
vertical-align: top; width: 33%;
color: #FFF; background-color: #666;
}
td.author { font-weight: bold; font-size: x-small; margin-left: 4em; }
td.author-text { font-size: x-small; }
/* info code from SantaKlauss at http://www.madaboutstyle.com/tooltip2.html */
a.info {
/* This is the key. */
position: relative;
z-index: 24;
text-decoration: none;
}
a.info:hover {
z-index: 25;
color: #FFF; background-color: #900;
}
a.info span { display: none; }
a.info:hover span.info {
/* The span will display just on :hover state. */
display: block;
position: absolute;
font-size: smaller;
top: 2em; left: -5em; width: 15em;
padding: 2px; border: 1px solid #333;
color: #900; background-color: #EEE;
text-align: left;
}
a { font-weight: bold; }
a:link { color: #900; background-color: transparent; }
a:visited { color: #633; background-color: transparent; }
a:active { color: #633; background-color: transparent; }
p { margin-left: 2em; margin-right: 2em; }
p.copyright { font-size: x-small; }
p.toc { font-size: small; font-weight: bold; margin-left: 3em; }
table.toc { margin: 0 0 0 3em; padding: 0; border: 0; vertical-align: text-top; }
td.toc { font-size: small; font-weight: bold; vertical-align: text-top; }
ol.text { margin-left: 2em; margin-right: 2em; }
ul.text { margin-left: 2em; margin-right: 2em; }
li { margin-left: 3em; }
/* RFC-2629 <spanx>s and <artwork>s. */
em { font-style: italic; }
strong { font-weight: bold; }
dfn { font-weight: bold; font-style: normal; }
cite { font-weight: normal; font-style: normal; }
tt { color: #036; }
tt, pre, pre dfn, pre em, pre cite, pre span {
font-family: "Courier New", Courier, monospace; font-size: small;
}
pre {
text-align: left; padding: 4px;
color: #000; background-color: #CCC;
}
pre dfn { color: #900; }
pre em { color: #66F; background-color: #FFC; font-weight: normal; }
pre .key { color: #33C; font-weight: bold; }
pre .id { color: #900; }
pre .str { color: #000; background-color: #CFF; }
pre .val { color: #066; }
pre .rep { color: #909; }
pre .oth { color: #000; background-color: #FCF; }
pre .err { background-color: #FCC; }
/* RFC-2629 <texttable>s. */
table.all, table.full, table.headers, table.none {
font-size: small; text-align: center; border-width: 2px;
vertical-align: top; border-collapse: collapse;
}
table.all, table.full { border-style: solid; border-color: black; }
table.headers, table.none { border-style: none; }
th {
font-weight: bold; border-color: black;
border-width: 2px 2px 3px 2px;
}
table.all th, table.full th { border-style: solid; }
table.headers th { border-style: none none solid none; }
table.none th { border-style: none; }
table.all td {
border-style: solid; border-color: #333;
border-width: 1px 2px;
}
table.full td, table.headers td, table.none td { border-style: none; }
hr { height: 1px; }
hr.insert {
width: 80%; border-style: none; border-width: 0;
color: #CCC; background-color: #CCC;
}
--></style>
</head>
<body>
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<table summary="layout" width="66%" border="0" cellpadding="0" cellspacing="0"><tr><td><table summary="layout" width="100%" border="0" cellpadding="2" cellspacing="1">
<tr><td class="header">Network Working Group</td><td class="header">E. Hammer-Lahav, Ed.</td></tr>
<tr><td class="header">Internet-Draft</td><td class="header">Yahoo!</td></tr>
<tr><td class="header">Obsoletes: <a href='http://tools.ietf.org/html/rfc5849'>5849</a> (if approved)</td><td class="header">D. Recordon</td></tr>
<tr><td class="header">Intended status: Standards Track</td><td class="header">Facebook</td></tr>
<tr><td class="header">Expires: March 25, 2012</td><td class="header">D. Hardt</td></tr>
<tr><td class="header"> </td><td class="header">Microsoft</td></tr>
<tr><td class="header"> </td><td class="header">September 22, 2011</td></tr>
</table></td></tr></table>
<h1><br />The OAuth 2.0 Authorization Protocol<br />draft-ietf-oauth-v2-22</h1>
<h3>Abstract</h3>
<p>
The OAuth 2.0 authorization protocol enables a third-party application to obtain limited
access to an HTTP service, either on behalf of a resource owner by orchestrating an approval
interaction between the resource owner and the HTTP service, or by allowing the third-party
application to obtain access on its own behalf. This specification replaces and obsoletes
the OAuth 1.0 protocol described in RFC 5849.
</p>
<h3>Status of this Memo</h3>
<p>
This Internet-Draft is submitted in full
conformance with the provisions of BCP 78 and BCP 79.</p>
<p>
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current
Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.</p>
<p>
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any time.
It is inappropriate to use Internet-Drafts as reference material or to cite
them other than as “work in progress.”</p>
<p>
This Internet-Draft will expire on March 25, 2012.</p>
<h3>Copyright Notice</h3>
<p>
Copyright (c) 2011 IETF Trust and the persons identified as the
document authors. All rights reserved.</p>
<p>
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.</p>
<a name="toc"></a><br /><hr />
<h3>Table of Contents</h3>
<p class="toc">
<a href="#anchor1">1.</a>
Introduction<br />
<a href="#anchor2">1.1.</a>
Roles<br />
<a href="#anchor3">1.2.</a>
Protocol Flow<br />
<a href="#anchor4">1.3.</a>
Authorization Grant<br />
<a href="#anchor5">1.3.1.</a>
Authorization Code<br />
<a href="#anchor6">1.3.2.</a>
Implicit<br />
<a href="#anchor7">1.3.3.</a>
Resource Owner Password Credentials<br />
<a href="#anchor8">1.3.4.</a>
Client Credentials<br />
<a href="#anchor9">1.4.</a>
Access Token<br />
<a href="#anchor10">1.5.</a>
Refresh Token<br />
<a href="#anchor11">1.6.</a>
Notational Conventions<br />
<a href="#anchor12">2.</a>
Client Registration<br />
<a href="#client-types">2.1.</a>
Client Types<br />
<a href="#client-identifier">2.2.</a>
Client Identifier<br />
<a href="#client-authentication">2.3.</a>
Client Authentication<br />
<a href="#anchor13">2.3.1.</a>
Client Password<br />
<a href="#anchor14">2.3.2.</a>
Other Authentication Methods<br />
<a href="#anchor15">2.4.</a>
Unregistered Clients<br />
<a href="#anchor16">3.</a>
Protocol Endpoints<br />
<a href="#anchor17">3.1.</a>
Authorization Endpoint<br />
<a href="#anchor18">3.1.1.</a>
Response Type<br />
<a href="#redirect-uri">3.1.2.</a>
Redirection Endpoint<br />
<a href="#anchor24">3.2.</a>
Token Endpoint<br />
<a href="#token-endpoint-auth">3.2.1.</a>
Client Authentication<br />
<a href="#scope">3.3.</a>
Access Token Scope<br />
<a href="#anchor25">4.</a>
Obtaining Authorization<br />
<a href="#grant-code">4.1.</a>
Authorization Code<br />
<a href="#code-authz-req">4.1.1.</a>
Authorization Request<br />
<a href="#anchor26">4.1.2.</a>
Authorization Response<br />
<a href="#anchor27">4.1.3.</a>
Access Token Request<br />
<a href="#anchor28">4.1.4.</a>
Access Token Response<br />
<a href="#grant-implicit">4.2.</a>
Implicit Grant<br />
<a href="#implicit-authz-req">4.2.1.</a>
Authorization Request<br />
<a href="#anchor29">4.2.2.</a>
Access Token Response<br />
<a href="#grant-password">4.3.</a>
Resource Owner Password Credentials<br />
<a href="#anchor30">4.3.1.</a>
Authorization Request and Response<br />
<a href="#anchor31">4.3.2.</a>
Access Token Request<br />
<a href="#anchor32">4.3.3.</a>
Access Token Response<br />
<a href="#grant-client">4.4.</a>
Client Credentials<br />
<a href="#anchor33">4.4.1.</a>
Authorization Request and Response<br />
<a href="#anchor34">4.4.2.</a>
Access Token Request<br />
<a href="#anchor35">4.4.3.</a>
Access Token Response<br />
<a href="#anchor36">4.5.</a>
Extensions<br />
<a href="#token-issue">5.</a>
Issuing an Access Token<br />
<a href="#token-response">5.1.</a>
Successful Response<br />
<a href="#token-errors">5.2.</a>
Error Response<br />
<a href="#token-refresh">6.</a>
Refreshing an Access Token<br />
<a href="#access-resource">7.</a>
Accessing Protected Resources<br />
<a href="#token-types">7.1.</a>
Access Token Types<br />
<a href="#extensions">8.</a>
Extensibility<br />
<a href="#new-types">8.1.</a>
Defining Access Token Types<br />
<a href="#anchor37">8.2.</a>
Defining New Endpoint Parameters<br />
<a href="#anchor38">8.3.</a>
Defining New Authorization Grant Types<br />
<a href="#response-type-ext">8.4.</a>
Defining New Authorization Endpoint Response Types<br />
<a href="#new-errors">8.5.</a>
Defining Additional Error Codes<br />
<a href="#anchor39">9.</a>
Native Applications<br />
<a href="#anchor40">10.</a>
Security Considerations<br />
<a href="#anchor41">10.1.</a>
Client Authentication<br />
<a href="#anchor42">10.2.</a>
Client Impersonation<br />
<a href="#anchor43">10.3.</a>
Access Tokens<br />
<a href="#anchor44">10.4.</a>
Refresh Tokens<br />
<a href="#anchor45">10.5.</a>
Authorization Codes<br />
<a href="#anchor46">10.6.</a>
Authorization Code Redirection URI Manipulation<br />
<a href="#anchor47">10.7.</a>
Resource Owner Password Credentials<br />
<a href="#anchor48">10.8.</a>
Request Confidentiality<br />
<a href="#anchor49">10.9.</a>
Endpoints Authenticity<br />
<a href="#anchor50">10.10.</a>
Credentials Guessing Attacks<br />
<a href="#anchor51">10.11.</a>
Phishing Attacks<br />
<a href="#CSRF">10.12.</a>
Cross-Site Request Forgery<br />
<a href="#anchor52">10.13.</a>
Clickjacking<br />
<a href="#anchor53">10.14.</a>
Code Injection and Input Validation<br />
<a href="#open-redirect">10.15.</a>
Open Redirectors<br />
<a href="#anchor54">11.</a>
IANA Considerations<br />
<a href="#type-registry">11.1.</a>
The OAuth Access Token Type Registry<br />
<a href="#anchor55">11.1.1.</a>
Registration Template<br />
<a href="#parameters-registry">11.2.</a>
The OAuth Parameters Registry<br />
<a href="#anchor56">11.2.1.</a>
Registration Template<br />
<a href="#anchor57">11.2.2.</a>
Initial Registry Contents<br />
<a href="#response-type-registry">11.3.</a>
The OAuth Authorization Endpoint Response Type Registry<br />
<a href="#anchor58">11.3.1.</a>
Registration Template<br />
<a href="#anchor59">11.3.2.</a>
Initial Registry Contents<br />
<a href="#error-registry">11.4.</a>
The OAuth Extensions Error Registry<br />
<a href="#anchor60">11.4.1.</a>
Registration Template<br />
<a href="#anchor61">12.</a>
Acknowledgements<br />
<a href="#anchor62">Appendix A.</a>
Editor's Notes<br />
<a href="#rfc.references1">13.</a>
References<br />
<a href="#rfc.references1">13.1.</a>
Normative References<br />
<a href="#rfc.references2">13.2.</a>
Informative References<br />
<a href="#rfc.authors">§</a>
Authors' Addresses<br />
</p>
<br clear="all" />
<a name="anchor1"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1"></a><h3>1.
Introduction</h3>
<p>
In the traditional client-server authentication model, the client requests an access
restricted resource (protected resource) on the server by authenticating with the server
using the resource owner's credentials. In order to provide third-party applications access
to restricted resources, the resource owner shares its credentials with the third-party.
This creates several problems and limitations:
</p>
<p>
</p>
<ul class="text">
<li>
Third-party applications are required to store the resource owner's credentials
for future use, typically a password in clear-text.
</li>
<li>
Servers are required to support password authentication, despite the security
weaknesses created by passwords.
</li>
<li>
Third-party applications gain overly broad access to the resource owner's protected
resources, leaving resource owners without any ability to restrict duration or access
to a limited subset of resources.
</li>
<li>
Resource owners cannot revoke access to an individual third-party without revoking
access to all third-parties, and must do so by changing their password.
</li>
<li>
Compromise of any third-party application results in compromise of the end-user’s
password and all of the data protected by that password.
</li>
</ul><p>
</p>
<p>
OAuth addresses these issues by introducing an authorization layer and separating the role
of the client from that of the resource owner. In OAuth, the client requests access to
resources controlled by the resource owner and hosted by the resource server, and is issued
a different set of credentials than those of the resource owner.
</p>
<p>
Instead of using the resource owner's credentials to access protected resources, the client
obtains an access token - a string denoting a specific scope, lifetime, and other access
attributes. Access tokens are issued to third-party clients by an authorization server with
the approval of the resource owner. The client uses the access token to access the
protected resources hosted by the resource server.
</p>
<p>
For example, an end-user (resource owner) can grant a printing service (client) access
to her protected photos stored at a photo sharing service (resource server), without
sharing her username and password with the printing service. Instead, she authenticates
directly with a server trusted by the photo sharing service (authorization server) which
issues the printing service delegation-specific credentials (access token).
</p>
<p>
This specification is designed for use with HTTP <a class='info' href='#RFC2616'>[RFC2616]<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” June 1999.</span><span>)</span></a>. The use of
OAuth with any transport protocol other than HTTP is undefined.
</p>
<a name="anchor2"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.1"></a><h3>1.1.
Roles</h3>
<p>
OAuth defines four roles:
</p>
<p>
</p>
<blockquote class="text"><dl>
<dt>resource owner</dt>
<dd>
An entity capable of granting access to a protected resource (e.g. end-user).
</dd>
<dt>resource server</dt>
<dd>
The server hosting the protected resources, capable of accepting and responding to
protected resource requests using access tokens.
</dd>
<dt>client</dt>
<dd>
An application making protected resource requests on behalf of the resource owner and
with its authorization.
</dd>
<dt>authorization server</dt>
<dd>
The server issuing access tokens to the client after successfully authenticating the
resource owner and obtaining authorization.
</dd>
</dl></blockquote><p>
</p>
<p>
The interaction between the authorization server and resource server is beyond the scope
of this specification. The authorization server may be the same server as the resource
server or a separate entity. A single authorization server may issue access tokens
accepted by multiple resource servers.
</p>
<a name="anchor3"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.2"></a><h3>1.2.
Protocol Flow</h3>
<br /><hr class="insert" />
<a name="Figure-1"></a>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+--------+ +---------------+
| |--(A)- Authorization Request ->| Resource |
| | | Owner |
| |<-(B)-- Authorization Grant ---| |
| | +---------------+
| |
| | +---------------+
| |--(C)-- Authorization Grant -->| Authorization |
| Client | | Server |
| |<-(D)----- Access Token -------| |
| | +---------------+
| |
| | +---------------+
| |--(E)----- Access Token ------>| Resource |
| | | Server |
| |<-(F)--- Protected Resource ---| |
+--------+ +---------------+
</pre></div><table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Figure 1: Abstract Protocol Flow </b></font><br /></td></tr></table><hr class="insert" />
<p>
The abstract flow illustrated in <a class='info' href='#Figure-1'>Figure 1<span> (</span><span class='info'>Abstract Protocol Flow</span><span>)</span></a> describes the interaction
between the four roles and includes the following steps:
</p>
<p>
</p>
<blockquote class="text"><dl>
<dt>(A)</dt>
<dd>
The client requests authorization from the resource owner. The authorization request
can be made directly to the resource owner (as shown), or preferably indirectly via
the authorization server as an intermediary.
</dd>
<dt>(B)</dt>
<dd>
The client receives an authorization grant which is a credential representing
the resource owner's authorization, expressed using one of four grant types defined
in this specification or using an extension grant type. The authorization grant type
depends on the method used by the client to request authorization and the types
supported by the authorization server.
</dd>
<dt>(C)</dt>
<dd>
The client requests an access token by authenticating with the authorization server
and presenting the authorization grant.
</dd>
<dt>(D)</dt>
<dd>
The authorization server authenticates the client and validates the authorization
grant, and if valid issues an access token.
</dd>
<dt>(E)</dt>
<dd>
The client requests the protected resource from the resource server and authenticates
by presenting the access token.
</dd>
<dt>(F)</dt>
<dd>
The resource server validates the access token, and if valid, serves the request.
</dd>
</dl></blockquote><p>
</p>
<a name="anchor4"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.3"></a><h3>1.3.
Authorization Grant</h3>
<p>
An authorization grant is a credential representing the resource owner's authorization
(to access its protected resources) used by the client to obtain an access token. This
specification defines four grant types: authorization code, implicit, resource owner
password credentials, and client credentials, as well as an extensibility mechanism for
defining additional types.
</p>
<a name="anchor5"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.3.1"></a><h3>1.3.1.
Authorization Code</h3>
<p>
The authorization code is obtained by using an authorization server as an intermediary
between the client and resource owner. Instead of requesting authorization directly
from the resource owner, the client directs the resource owner to an authorization
server (via its user-agent as defined in <a class='info' href='#RFC2616'>[RFC2616]<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” June 1999.</span><span>)</span></a>), which in turn
directs the resource owner back to the client with the authorization code.
</p>
<p>
Before directing the resource owner back to the client with the authorization code, the
authorization server authenticates the resource owner and obtains authorization.
Because the resource owner only authenticates with the authorization server, the
resource owner's credentials are never shared with the client.
</p>
<p>
The authorization code provides a few important security benefits such as the ability
to authenticate the client, and the transmission of the access token directly to
the client without passing it through the resource owner's user-agent, potentially
exposing it to others, including the resource owner.
</p>
<a name="anchor6"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.3.2"></a><h3>1.3.2.
Implicit</h3>
<p>
The implicit grant is a simplified authorization code flow optimized for clients
implemented in a browser using a scripting language such as JavaScript. In the implicit
flow, instead of issuing the client an authorization code, the client is issued an
access token directly (as the result of the resource owner authorization). The grant
type is implicit as no intermediate credentials (such as an authorization code) are
issued (and later used to obtain an access token).
</p>
<p>
When issuing an implicit grant, the authorization server does not authenticate the
client. In some cases, the client identity can be verified via the redirection URI
used to deliver the access token to the client. The access token may be exposed to the
resource owner or other applications with access to the resource owner's user-agent.
</p>
<p>
Implicit grants improve the responsiveness and efficiency of some clients (such as a
client implemented as an in-browser application) since it reduces the number of round
trips required to obtain an access token. However, this convenience should be weighed
against the security implications of using implicit grants, especially when the
authorization code grant type is available.
</p>
<a name="anchor7"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.3.3"></a><h3>1.3.3.
Resource Owner Password Credentials</h3>
<p>
The resource owner password credentials (i.e. username and password) can be used
directly as an authorization grant to obtain an access token. The credentials should
only be used when there is a high degree of trust between the resource owner and the
client (e.g. its device operating system or a highly privileged application), and
when other authorization grant types are not available (such as an authorization code).
</p>
<p>
Even though this grant type requires direct client access to the resource owner
credentials, the resource owner credentials are used for a single request and are
exchanged for an access token. This grant type can eliminate the need for the client
to store the resource owner credentials for future use, by exchanging the credentials
with a long-lived access token or refresh token.
</p>
<a name="anchor8"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.3.4"></a><h3>1.3.4.
Client Credentials</h3>
<p>
The client credentials (or other forms of client authentication) can be used as an
authorization grant when the authorization scope is limited to the protected resources
under the control of the client, or to protected resources previously arranged with the
authorization server. Client credentials are used as an authorization grant typically
when the client is acting on its own behalf (the client is also the resource owner), or
is requesting access to protected resources based on an authorization previously
arranged with the authorization server.
</p>
<a name="anchor9"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.4"></a><h3>1.4.
Access Token</h3>
<p>
Access tokens are credentials used to access protected resources. An access token is a
string representing an authorization issued to the client. The string is usually opaque
to the client. Tokens represent specific scopes and durations of access, granted by the
resource owner, and enforced by the resource server and authorization server.
</p>
<p>
The token may denote an identifier used to retrieve the authorization information, or
self-contain the authorization information in a verifiable manner (i.e. a token string
consisting of some data and a signature). Additional authentication credentials, which
are beyond the scope of this specification, may be required in order for the client to
use a token.
</p>
<p>
The access token provides an abstraction layer, replacing different authorization
constructs (e.g. username and password) with a single token understood by the resource
server. This abstraction enables issuing access tokens more restrictive than the
authorization grant used to obtain them, as well as removing the resource server's need to
understand a wide range of authentication methods.
</p>
<p>
Access tokens can have different formats, structures, and methods of utilization (e.g.
cryptographic properties) based on the resource server security requirements. Access token
attributes and the methods used to access protected resources are beyond the scope of this
specification and are defined by companion specifications.
</p>
<a name="anchor10"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.5"></a><h3>1.5.
Refresh Token</h3>
<p>
Refresh tokens are credentials used to obtain access tokens. Refresh tokens are issued to
the client by the authorization server and are used to obtain a new access token when the
current access token becomes invalid or expires, or to obtain additional access tokens
with identical or narrower scope (access tokens may have a shorter lifetime and fewer
permissions than authorized by the resource owner). Issuing a refresh token is optional.
If the authorization server issues a refresh token, it is included when issuing an access
token.
</p>
<p>
A refresh token is a string representing the authorization granted to the client by the
resource owner. The string is usually opaque to the client. The token denotes an
identifier used to retrieve the authorization information. Unlike access tokens, refresh
tokens are intended for use only with authorization servers and are never sent to
resource servers.
</p><br /><hr class="insert" />
<a name="Figure-2"></a>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+--------+ +---------------+
| |--(A)------- Authorization Grant --------->| |
| | | |
| |<-(B)----------- Access Token -------------| |
| | & Refresh Token | |
| | | |
| | +----------+ | |
| |--(C)---- Access Token ---->| | | |
| | | | | |
| |<-(D)- Protected Resource --| Resource | | Authorization |
| Client | | Server | | Server |
| |--(E)---- Access Token ---->| | | |
| | | | | |
| |<-(F)- Invalid Token Error -| | | |
| | +----------+ | |
| | | |
| |--(G)----------- Refresh Token ----------->| |
| | | |
| |<-(H)----------- Access Token -------------| |
+--------+ & Optional Refresh Token +---------------+
</pre></div><table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Figure 2: Refreshing an Expired Access Token </b></font><br /></td></tr></table><hr class="insert" />
<p>
The flow illustrated in <a class='info' href='#Figure-2'>Figure 2<span> (</span><span class='info'>Refreshing an Expired Access Token</span><span>)</span></a> includes the following steps:
</p>
<p>
</p>
<blockquote class="text"><dl>
<dt>(A)</dt>
<dd>
The client requests an access token by authenticating with the authorization server,
and presenting an authorization grant.
</dd>
<dt>(B)</dt>
<dd>
The authorization server authenticates the client and validates the authorization
grant, and if valid issues an access token and a refresh token.
</dd>
<dt>(C)</dt>
<dd>
The client makes a protected resource request to the resource server by presenting
the access token.
</dd>
<dt>(D)</dt>
<dd>
The resource server validates the access token, and if valid, serves the request.
</dd>
<dt>(E)</dt>
<dd>
Steps (C) and (D) repeat until the access token expires. If the client knows the
access token expired, it skips to step (G), otherwise it makes another protected
resource request.
</dd>
<dt>(F)</dt>
<dd>
Since the access token is invalid, the resource server returns an invalid token
error.
</dd>
<dt>(G)</dt>
<dd>
The client requests a new access token by authenticating with the authorization
server and presenting the refresh token. The client authentication requirements are
based on the client type and on the authorization server policies.
</dd>
<dt>(H)</dt>
<dd>
The authorization server authenticates the client and validates the refresh token,
and if valid issues a new access token (and optionally, a new refresh token).
</dd>
</dl></blockquote><p>
</p>
<a name="anchor11"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.6"></a><h3>1.6.
Notational Conventions</h3>
<p>
The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL NOT', 'SHOULD', 'SHOULD
NOT', 'RECOMMENDED', 'MAY', and 'OPTIONAL' in this specification are to be interpreted as
described in <a class='info' href='#RFC2119'>[RFC2119]<span> (</span><span class='info'>Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” March 1997.</span><span>)</span></a>.
</p>
<p>
This specification uses the Augmented Backus-Naur Form (ABNF) notation of
<a class='info' href='#RFC5234'>[RFC5234]<span> (</span><span class='info'>Crocker, D. and P. Overell, “Augmented BNF for Syntax Specifications: ABNF,” January 2008.</span><span>)</span></a>.
</p>
<p>
Certain security-related terms are to be understood in the sense defined in
<a class='info' href='#RFC4949'>[RFC4949]<span> (</span><span class='info'>Shirey, R., “Internet Security Glossary, Version 2,” August 2007.</span><span>)</span></a>. These terms include, but are not limited to, 'attack',
'authentication', 'authorization', 'certificate', 'confidentiality', 'credential',
'encryption', 'identity', 'sign', 'signature', 'trust', 'validate', and 'verify'.
</p>
<p>
Unless otherwise noted, all the protocol parameter names and values are case sensitive.
</p>
<a name="anchor12"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2"></a><h3>2.
Client Registration</h3>
<p>
Before initiating the protocol, the client registers with the authorization server. The
means through which the client registers with the authorization server are beyond the
scope of this specification, but typically involve end-user interaction with an HTML
registration form.
</p>
<p>
Client registration does not require a direct interaction between the client and the
authorization server. When supported by the authorization server, registration can rely
on other means for establishing trust and obtaining the required client properties (e.g.
redirection URI, client type). For example, registration can be accomplished using a
self-issued or third-party-issued assertion, or by the authorization server performing
client discovery using a trusted channel.
</p>
<p>
When registering a client, the client developer:
</p>
<p>
</p>
<ul class="text">
<li>
specifies the client type as described in <a class='info' href='#client-types'>Section 2.1<span> (</span><span class='info'>Client Types</span><span>)</span></a>,
</li>
<li>
provides its client redirection URIs as described in
<a class='info' href='#redirect-uri'>Section 3.1.2<span> (</span><span class='info'>Redirection Endpoint</span><span>)</span></a>, and
</li>
<li>
includes any other information required by the authorization server (e.g. application
name, website, description, logo image, the acceptance of legal terms).
</li>
</ul><p>
</p>
<a name="client-types"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.1"></a><h3>2.1.
Client Types</h3>
<p>
OAuth defines two client types, based on their ability to authenticate securely with the
authorization server (i.e. ability to maintain the confidentiality of their client
credentials):
</p>
<p>
</p>
<blockquote class="text"><dl>
<dt>confidential</dt>
<dd>
Clients capable of maintaining the confidentiality of their credentials (e.g.
client implemented on a secure server with restricted access to the client
credentials), or capable of secure client authentication using other means.
</dd>
<dt>public</dt>
<dd>
Clients incapable of maintaining the confidentiality of their credentials (e.g.
clients executing on the resource owner's device such as an installed native
application or a web browser-based application), and incapable of secure client
authentication via any other means.
</dd>
</dl></blockquote><p>
</p>
<p>
The client type designation is based on the authorization server's definition of secure
authentication and its acceptable exposure levels of client credentials.
</p>
<p>
This specification has been designed around the following client profiles:
</p>
<p>
</p>
<blockquote class="text"><dl>
<dt>web application</dt>
<dd>
A web application is a confidential client running on a web server. Resource owners access
the client via an HTML user interface rendered in a user-agent on the resource
owner's device. The client credentials as well as any access token issued to the
client are stored on the web server and are not exposed to or accessible by the
resource owner.
</dd>
<dt>user-agent-based application</dt>
<dd>
A user-agent-based application is a public client in which the client code is
downloaded from a web server and executes within a user-agent (e.g. web browser) on
the resource owner's device. Protocol data and credentials are easily accessible (and
often visible) to the resource owner. Since such applications reside within the
user-agent, they can make seamless use of the user-agent capabilities when requesting
authorization.
</dd>
<dt>native application</dt>
<dd>
A native application is a public client installed and executed on the resource
owner's device. Protocol data and credentials are accessible to the resource owner.
It is assumed that any client authentication credentials included in the application
can be extracted. On the other hand, dynamically issued credentials such access
tokens or refresh tokens can receive an acceptable level of protection. At a
minimum, these credentials are protected from hostile servers which the application
may interact with. On some platform these credentials might be protected from other
applications residing on the same device.
</dd>
</dl></blockquote><p>
</p>
<a name="client-identifier"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.2"></a><h3>2.2.
Client Identifier</h3>
<p>
The authorization server issues the registered client a client identifier - a unique
string representing the registration information provided by the client. The client
identifier is not a secret, it is exposed to the resource owner, and MUST NOT be used
alone for client authentication.
</p>
<a name="client-authentication"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3"></a><h3>2.3.
Client Authentication</h3>
<p>
If the client type is confidential, the client and authorization server establish a client