Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Backbone.js

You're reading from   Mastering Backbone.js Design and build scalable web applications using Backbone.js

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher Packt
ISBN-13 9781783288496
Length 278 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Abiee Echamea Abiee Echamea
Author Profile Icon Abiee Echamea
Abiee Echamea
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Architecture of a Backbone application 2. Managing Views FREE CHAPTER 3. Model Bindings 4. Modular Code 5. Dealing with Files 6. Store data in the Browser 7. Build Like a Pro 8. Testing Backbone Applications 9. Deploying to Production 10. Authentication Index

Implementing OAuth authentication

As we did for Basic Auth, we are going to build a server-side implementation of the OAuth2 protocol. As the Backbone App and Server App are both built by us, the best grant type to choose is Resource Owner Password Credentials Grant.

A difference from Basic Auth is that OAuth2 needs to add an endpoint that is used to issue access and refresh tokens. As described in RFC-6749, the requests made to this endpoint should include the following:

The client makes a request to the token endpoint by adding the following parameters using the "application/x-www-form-urlencoded":

grant_type: REQUIRED. Value MUST be set to "password".

username: REQUIRED. The resource owner username.

Password: REQUIRED. The resource owner password.

A valid request will look as shown in the following:

POST /api/oauth/token HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded

grant_type=password&username=john&password=doe

Then, the server will...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image