38
38
< h1 id ="introduction "> Introduction</ h1 >
39
39
< p >
40
40
Create AngularJS apps that connects to any OAuth 2.0 server using the client side
41
- flow (aka < a href ="http://tools.ietf.org/html/rfc6749#section-1.3.2 "> OAuth 2.0 Implicit Grant</ a > )
41
+ flow (aka < a href ="http://tools.ietf.org/html/rfc6749#section-1.3.2 " target =" _blank " > OAuth 2.0 Implicit Grant</ a > )
42
42
</ p >
43
43
</ div >
44
44
</ section >
@@ -51,7 +51,7 @@ <h1 id="getting-started">Getting Started</h1>
51
51
< h2 > Installation</ h2 >
52
52
53
53
< p >
54
- Install oauth-ng using < a href ="http://bower.io/ "> Bower</ a >
54
+ Install oauth-ng using < a href ="http://bower.io/ " target =" _blank " > Bower</ a >
55
55
</ p >
56
56
57
57
< pre > < code > $ bower install oauth-ng --save</ code > </ pre >
@@ -75,7 +75,7 @@ <h2>Basic Example</h2>
75
75
</ body > </ xmp > </ code > </ pre >
76
76
77
77
< p >
78
- To fully understand how it works read the < a href ="#howto "> how to </ a > section .
78
+ To fully understand how it works read the next < a href ="#howto "> section </ a > .
79
79
</ p >
80
80
81
81
</ div >
@@ -86,18 +86,18 @@ <h2>Basic Example</h2>
86
86
< div class ="content ">
87
87
88
88
89
- < h1 id ="howto "> How To </ h1 >
89
+ < h1 id ="howto "> Create your first app with oauth-ng </ h1 >
90
90
< p >
91
91
In this section you will learn how to use the directive to authorize an OAuth 2.0 server
92
- through the creation of a real project (in 10 minutues) .
92
+ through the creation of a real project. It will take less than 15 minutues.
93
93
</ p >
94
94
95
95
96
96
< h2 id ="setup "> Setup</ h2 >
97
97
98
98
< p >
99
99
To build our app we'll use < a href ="http://yeoman.io " target ="blank "> Yeoman</ a > , a collection of tools
100
- and frameworks that can help developers quickly build web applications.
100
+ and frameworks helping developers to quickly build web applications.
101
101
</ p >
102
102
103
103
< ul >
@@ -170,8 +170,8 @@ <h2>Install oauth-ng</h2>
170
170
< pre > < code > $ bower install oauth-ng --save</ code > </ pre >
171
171
172
172
< p >
173
- With this command oauth-ng and all its dependencies are downloaded. To automatically
174
- add them to your index page stop and restart the server.
173
+ Now you have < code > oauth-ng</ code > and all its dependencies ready to be used.
174
+ To automatically add them to your index page, stop and restart the server.
175
175
</ p >
176
176
177
177
< pre > < code > $ grunt serve</ code > </ pre >
@@ -195,11 +195,10 @@ <h2>AngularJS app definition</h2>
195
195
< h2 id ="server "> OAuth 2.0 Server</ h2 >
196
196
197
197
< p >
198
- To test the directive we created a basic OAuth 2.0 authorization server (using
199
- < a href ="https://github.com/doorkeeper-gem/doorkeeper "> Ruby</ a > ).
198
+ To test the directive we created a basic OAuth 2.0 authorization server.
200
199
201
200
< ul >
202
- < li > < strong > uri </ strong > - http://oauth-ng-server.herokuapp.com</ li >
201
+ < li > http://oauth-ng-server.herokuapp.com</ li >
203
202
</ ul >
204
203
</ p >
205
204
@@ -211,7 +210,8 @@ <h2 id="server">OAuth 2.0 Server</h2>
211
210
< h2 > Identify your application</ h2 >
212
211
213
212
< p >
214
- To make the directive work you need a registered application. Here one.
213
+ To make the directive work you need a registered application to get its
214
+ < code > client-id</ code > and < code > redirect-uri</ code > .
215
215
</ p >
216
216
217
217
< ul >
@@ -220,15 +220,15 @@ <h2>Identify your application</h2>
220
220
</ ul >
221
221
222
222
< p >
223
- Use the < code > client-id </ code > and the < code > redirect-uri </ code > above or
224
- < a href ="" target =" blank " > register a new one </ a > .
223
+ Use the credentials above or < a href ="" target =" blank " > register </ a >
224
+ a new application .
225
225
</ p >
226
226
227
227
228
228
< h2 > Add the oauth-ng directive</ h2 >
229
229
230
230
< p >
231
- Open the main.html view and place the oauth directive .
231
+ Open the main.html view and place the < code > oauth</ code > tag with the needed configurations .
232
232
</ p >
233
233
234
234
< pre > < code > < xmp > // apps/views/main.html
@@ -240,7 +240,7 @@ <h2>Add the oauth-ng directive</h2>
240
240
</ oauth2 > </ xmp > </ code > </ pre >
241
241
242
242
< p >
243
- Follows a description for the used attributes.
243
+ Here a description for the used attributes.
244
244
</ p >
245
245
246
246
< table class ="table table-labeled ">
@@ -287,7 +287,7 @@ <h2>You're done!</h2>
287
287
< p >
288
288
Nothing else to do. Open your index page, click the < code > Login</ code > link,
289
289
authorize your app and get the authenticated user info. You are now ready to
290
- access to your API in a secure way .
290
+ access to your API using OAuth 2.0 and AngularJS .
291
291
</ p >
292
292
293
293
< p >
@@ -395,7 +395,7 @@ <h1 id="configurations">Configurations</h1>
395
395
396
396
< section >
397
397
< div class ="content ">
398
- < h1 id ="templates "> Customizations</ h1 >
398
+ < h1 id ="customizations "> Customizations</ h1 >
399
399
400
400
< p >
401
401
The oauth directive comes to life with customization in mind. You can easily define
@@ -523,8 +523,9 @@ <h1>Custom CSS</h1>
523
523
< h1 > Custom Template</ h1 >
524
524
525
525
< p >
526
- If the custom template does not fit for you, you can create a personalized one.
527
- Below you can see the default template used from the directive.
526
+ When the custom template does not satisfy your needs (e.g. you want to show the user email
527
+ when logged in), you can create a new one. To have an idea of what a template looks like,
528
+ see the code below (related to the default template).
528
529
</ p >
529
530
530
531
< pre > < code > < xmp > < span class ="oauth ">
@@ -534,8 +535,7 @@ <h1>Custom Template</h1>
534
535
</ span > </ xmp > </ code > </ pre >
535
536
536
537
< p >
537
- To create a new one create your personalized HTML and make it interact with the oauth
538
- internal API.
538
+ To create your new template, define the HTML and make it work using the following internal API.
539
539
</ p >
540
540
541
541
< table class ="table smaller-titles ">
@@ -572,16 +572,16 @@ <h1>Custom Template</h1>
572
572
</ table >
573
573
574
574
< p >
575
- Suppose you defined a new template in < code > views/templates/custom.html</ code > .
576
- Now you need to let the directive know about the new template . You can do it in two ways.
575
+ Now, supposing you have defined a new template in < code > views/templates/custom.html</ code > ,
576
+ you need to let the directive know about its existence . You can do this in two ways.
577
577
</ p >
578
578
579
579
< ul >
580
580
< li > Setting the template attribute</ li >
581
581
< li > Firing the template event</ li >
582
582
</ ul >
583
583
584
- < h2 > Template attribute</ h2 >
584
+ < h2 > 1 - Template attribute</ h2 >
585
585
586
586
< p >
587
587
Set the template path (or uri) as value for the template attribute.
@@ -595,7 +595,7 @@ <h2>Template attribute</h2>
595
595
profile ="<profile-uri> ">
596
596
</ oauth2 > </ xmp > </ code > </ pre >
597
597
598
- < h2 > Template event</ h2 >
598
+ < h2 > 2 - Template event</ h2 >
599
599
600
600
< p >
601
601
Fires the update template event passing the template path (or uri) as param.
@@ -604,8 +604,8 @@ <h2>Template event</h2>
604
604
< pre > < code > < xmp > $rootScope.$broadcast('oauth:template:update', 'views/templates/custom.html');</ xmp > </ code > </ pre >
605
605
606
606
< p >
607
- The main advantage of using the update template event is that it can change the
608
- HTML view of your directive at any moment of its life .
607
+ Use this solution when you need to update the directive at runtime. For all
608
+ other cases, use the template attribute .
609
609
</ p >
610
610
611
611
</ div >
@@ -665,7 +665,7 @@ <h1 id="events">Events</h1>
665
665
</ td >
666
666
< td >
667
667
Listening for runtime the template change.< br >
668
- See examples in the < a href ="#customization "> customization</ a > section.
668
+ See examples in the < a href ="#customizations "> customization</ a > section.
669
669
</ td >
670
670
</ tr >
671
671
</ tbody >
@@ -688,36 +688,86 @@ <h1 id="events">Events</h1>
688
688
});
689
689
690
690
$scope.$on('oauth:expired', function(event) {
691
- console.log('The access token is expired. Please refresh the login ');
691
+ console.log('The access token is expired. Please refresh. ');
692
692
});</ xmp > </ code > </ pre >
693
693
694
694
695
695
</ div >
696
696
</ section >
697
697
698
698
699
+ < section >
700
+ < div class ="content ">
701
+ < h1 id ="profile "> Logged in or logged out?</ h1 >
702
+
703
+ < p >
704
+ Inject the < code > AccessToken.get()</ code > service to understand if the user is logged in or out.
705
+ </ p >
706
+
707
+ < pre > < code > < xmp > $scope.logged = !!AccessToken.get();</ xmp > </ code > </ pre >
708
+
709
+ < p >
710
+ The < code > AccessToken.get()</ code > method returns < code > null</ code > when the user is logged
711
+ out and the access token representation when the user is logged in (see below).
712
+ </ p >
713
+
714
+
715
+ < pre > < code > < xmp > {
716
+ "access_token": "9ce03e06f037180c2dcfa8b278217eb56d747730c69xxx",
717
+ "token_type": "bearer",
718
+ "expires_in": 7200,
719
+ "state": "remember-me"
720
+ }</ xmp > </ code > </ pre >
721
+
722
+ </ div >
723
+ </ section >
724
+
725
+
726
+ < section >
727
+ < div class ="content ">
728
+ < h1 id ="profile "> Profile resource</ h1 >
729
+
730
+ < p >
731
+ When a user signs in, the profile is accessible through the < code > Profile</ code > service.
732
+ </ p >
733
+
734
+ < pre > < code > < xmp > $scope.profile = Profile.get();</ xmp > </ code > </ pre >
735
+
736
+ < p >
737
+ This profile is accessible only when the < code > profile-uri</ code > attribute is defined.
738
+ </ p >
739
+
740
+ </ div >
741
+ </ section >
742
+
743
+
699
744
< section >
700
745
< div class ="content ">
701
746
< h1 id ="links "> Links</ h1 >
702
747
703
748
< ul >
704
749
< li >
705
- < a href ="https://github.com/lelylan/lelylan -ng/ " target ="blank "> Github Repository</ a >
750
+ < a href ="https://github.com/andreareginato/oauth -ng/ " target ="blank "> Github Repository</ a >
706
751
</ li >
707
752
< li >
708
- < a href ="https://dev.lelylan.com " target ="blank "> Lelylan Dev Center</ a >
709
- </ li >
710
- < li >
711
- < a href ="https://lelylan.com " target ="blank "> Lelylan website</ a >
712
- </ li >
713
- < li >
714
- < a href ="https://twitter.com/lelylan " target ="blank "> Twitter @lelylan</ a >
753
+ < a href ="https://twitter.com/andreareginato " target ="blank "> @andreareginato</ a >
715
754
</ li >
716
755
</ ul >
717
756
</ div >
718
757
</ section >
719
758
720
759
760
+ < section >
761
+ < div class ="content ">
762
+ < h1 id ="thanks "> Thanks</ h1 >
763
+
764
+ < p >
765
+ Project created and released as open-source thanks to < a href ="http://lelylan.com "> Lelylan</ a > .
766
+ </ p >
767
+
768
+ </ div >
769
+ </ section >
770
+
721
771
722
772
</ body >
723
773
</ html >
0 commit comments