Skip to content

Commit 60b0a54

Browse files
Completed first draft of the oauth-ng documentation
1 parent cc91245 commit 60b0a54

File tree

1 file changed

+88
-38
lines changed

1 file changed

+88
-38
lines changed

index.html

Lines changed: 88 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<h1 id="introduction">Introduction</h1>
3939
<p>
4040
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>)
4242
</p>
4343
</div>
4444
</section>
@@ -51,7 +51,7 @@ <h1 id="getting-started">Getting Started</h1>
5151
<h2>Installation</h2>
5252

5353
<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>
5555
</p>
5656

5757
<pre><code>$ bower install oauth-ng --save</code></pre>
@@ -75,7 +75,7 @@ <h2>Basic Example</h2>
7575
</body></xmp></code></pre>
7676

7777
<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>.
7979
</p>
8080

8181
</div>
@@ -86,18 +86,18 @@ <h2>Basic Example</h2>
8686
<div class="content">
8787

8888

89-
<h1 id="howto">How To</h1>
89+
<h1 id="howto">Create your first app with oauth-ng</h1>
9090
<p>
9191
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.
9393
</p>
9494

9595

9696
<h2 id="setup">Setup</h2>
9797

9898
<p>
9999
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.
101101
</p>
102102

103103
<ul>
@@ -170,8 +170,8 @@ <h2>Install oauth-ng</h2>
170170
<pre><code>$ bower install oauth-ng --save</code></pre>
171171

172172
<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.
175175
</p>
176176

177177
<pre><code>$ grunt serve</code></pre>
@@ -195,11 +195,10 @@ <h2>AngularJS app definition</h2>
195195
<h2 id="server">OAuth 2.0 Server</h2>
196196

197197
<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.
200199

201200
<ul>
202-
<li><strong>uri</strong> - http://oauth-ng-server.herokuapp.com</li>
201+
<li>http://oauth-ng-server.herokuapp.com</li>
203202
</ul>
204203
</p>
205204

@@ -211,7 +210,8 @@ <h2 id="server">OAuth 2.0 Server</h2>
211210
<h2>Identify your application</h2>
212211

213212
<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>.
215215
</p>
216216

217217
<ul>
@@ -220,15 +220,15 @@ <h2>Identify your application</h2>
220220
</ul>
221221

222222
<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.
225225
</p>
226226

227227

228228
<h2>Add the oauth-ng directive</h2>
229229

230230
<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.
232232
</p>
233233

234234
<pre><code><xmp>// apps/views/main.html
@@ -240,7 +240,7 @@ <h2>Add the oauth-ng directive</h2>
240240
</oauth2></xmp></code></pre>
241241

242242
<p>
243-
Follows a description for the used attributes.
243+
Here a description for the used attributes.
244244
</p>
245245

246246
<table class="table table-labeled">
@@ -287,7 +287,7 @@ <h2>You're done!</h2>
287287
<p>
288288
Nothing else to do. Open your index page, click the <code>Login</code> link,
289289
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.
291291
</p>
292292

293293
<p>
@@ -395,7 +395,7 @@ <h1 id="configurations">Configurations</h1>
395395

396396
<section>
397397
<div class="content">
398-
<h1 id="templates">Customizations</h1>
398+
<h1 id="customizations">Customizations</h1>
399399

400400
<p>
401401
The oauth directive comes to life with customization in mind. You can easily define
@@ -523,8 +523,9 @@ <h1>Custom CSS</h1>
523523
<h1>Custom Template</h1>
524524

525525
<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).
528529
</p>
529530

530531
<pre><code><xmp><span class="oauth">
@@ -534,8 +535,7 @@ <h1>Custom Template</h1>
534535
</span></xmp></code></pre>
535536

536537
<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.
539539
</p>
540540

541541
<table class="table smaller-titles">
@@ -572,16 +572,16 @@ <h1>Custom Template</h1>
572572
</table>
573573

574574
<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.
577577
</p>
578578

579579
<ul>
580580
<li>Setting the template attribute</li>
581581
<li>Firing the template event</li>
582582
</ul>
583583

584-
<h2>Template attribute</h2>
584+
<h2>1 - Template attribute</h2>
585585

586586
<p>
587587
Set the template path (or uri) as value for the template attribute.
@@ -595,7 +595,7 @@ <h2>Template attribute</h2>
595595
profile="<profile-uri>">
596596
</oauth2></xmp></code></pre>
597597

598-
<h2>Template event</h2>
598+
<h2>2 - Template event</h2>
599599

600600
<p>
601601
Fires the update template event passing the template path (or uri) as param.
@@ -604,8 +604,8 @@ <h2>Template event</h2>
604604
<pre><code><xmp>$rootScope.$broadcast('oauth:template:update', 'views/templates/custom.html');</xmp></code></pre>
605605

606606
<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.
609609
</p>
610610

611611
</div>
@@ -665,7 +665,7 @@ <h1 id="events">Events</h1>
665665
</td>
666666
<td>
667667
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.
669669
</td>
670670
</tr>
671671
</tbody>
@@ -688,36 +688,86 @@ <h1 id="events">Events</h1>
688688
});
689689

690690
$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.');
692692
});</xmp></code></pre>
693693

694694

695695
</div>
696696
</section>
697697

698698

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+
699744
<section>
700745
<div class="content">
701746
<h1 id="links">Links</h1>
702747

703748
<ul>
704749
<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>
706751
</li>
707752
<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>
715754
</li>
716755
</ul>
717756
</div>
718757
</section>
719758

720759

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+
721771

722772
</body>
723773
</html>

0 commit comments

Comments
 (0)