Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

jaredhanson/passport-oauth2-client-password

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OAuth 2.0 client password authentication strategy forPassport.

This module lets you authenticate requests containing client credentials in therequest body, asdefinedby the OAuth 2.0 specification. These credentials are typically used protectthe token endpoint and used as an alternative to HTTP Basic authentication.


Advertisement
Node.js API Masterclass With Express & MongoDB
Create a real world backend for a bootcamp directory app


npmbuildcoverage...

Install

$ npm install passport-oauth2-client-password

Usage

Configure Strategy

The OAuth 2.0 client password authentication strategy authenticates clientsusing a client ID and client secret. The strategy requires averify callback,which accepts those credentials and callsdone providing a client.

passport.use(newClientPasswordStrategy(function(clientId,clientSecret,done){Clients.findOne({clientId:clientId},function(err,client){if(err){returndone(err);}if(!client){returndone(null,false);}if(client.clientSecret!=clientSecret){returndone(null,false);}returndone(null,client);});}));

Authenticate Requests

Usepassport.authenticate(), specifying the'oauth2-client-password'strategy, to authenticate requests. This strategy is typically used incombination with HTTP Basic authentication (as provided bypassport-http),allowing clients to include credentials in the request body.

For example, as route middleware in anExpressapplication, usingOAuth2orizemiddleware to implement the token endpoint:

app.get('/profile',   passport.authenticate(['basic', 'oauth2-client-password'], { session: false }),  oauth2orize.token());

Examples

Theexampleincluded withOAuth2orizedemonstrates how to implement a complete OAuth 2.0 authorization server.ClientPasswordStrategy is used to authenticate clients as they request accesstokens from the token endpoint.

Tests

$ npm install --dev$ maketest

Credits

License

The MIT License

Copyright (c) 2012-2013 Jared Hanson <http://jaredhanson.net/>

Sponsor this project

    Packages

    No packages published

    Contributors4

    •  
    •  
    •  
    •  

    [8]ページ先頭

    ©2009-2025 Movatter.jp