-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2821b82
Showing
51 changed files
with
22,422 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
reports/ | ||
lib/ | ||
|
||
# Mac OS X | ||
.DS_Store | ||
|
||
# Node.js | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
docs/ | ||
example/ | ||
reports/ | ||
test/ | ||
lib/test/ | ||
docs | ||
|
||
tsconfig.json | ||
tslint.json | ||
.prettierrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"printWidth": 80, | ||
"parser": "typescript", | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Snap Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# passport-snapchat | ||
|
||
[Passport](http://passportjs.org/) strategy for authenticating with [Snapchat](http://www.snapchat.com/) | ||
using the OAuth 2.0 API. | ||
|
||
This module lets you authenticate using Snapchat in your Node.js applications. | ||
By plugging into Passport, Snapchat authorization can easily and unobtrusively be integrated | ||
into any application or framework that supports | ||
[Connect](http://www.senchalabs.org/connect/)-style middleware, including | ||
[Express](http://expressjs.com/). | ||
|
||
## Install | ||
|
||
$ npm install passport-snapchat | ||
|
||
## [API Reference](https://snapchat.github.io/passport-snapchat/) | ||
|
||
## Usage | ||
|
||
#### Create an Application | ||
|
||
Before using `passport-snapchat`, you must register an application with | ||
Snapchat. If you have not already done so, a new application can be created within the | ||
[Snap Kit Developer Portal](https://kit.snapchat.com/portal). Your application will | ||
be issued an app ID and app secret, which need to be provided to the strategy. | ||
You will also need to configure a redirect URI which matches the route in your | ||
application. | ||
|
||
#### Configure Strategy | ||
|
||
The Snapchat authorization strategy authenticates users using a Snapchat | ||
account and OAuth 2.0 tokens. The app ID and secret obtained when creating an | ||
application are supplied as options when creating the strategy. The strategy | ||
also requires a `verify` callback, which receives the access token and optional | ||
refresh token, as well as `profile` which contains the authenticated user's | ||
Snapchat profile. The `verify` callback must call `cb` providing a user to | ||
complete authorization. | ||
|
||
```js | ||
passport.use(new SnapchatStrategy({ | ||
clientID: snapchat_APP_ID, | ||
clientSecret: snapchat_APP_SECRET, | ||
callbackURL: "http://localhost:3000/auth/snapchat/callback" | ||
}, | ||
function(accessToken, refreshToken, profile, cb) { | ||
User.findOrCreate({ snapchatId: profile.id }, function (err, user) { | ||
return cb(err, user); | ||
}); | ||
} | ||
)); | ||
``` | ||
|
||
#### Authenticate Requests | ||
|
||
Use `passport.authenticate()`, specifying the `'snapchat'` strategy, to | ||
authenticate requests. | ||
|
||
For example, as route middleware in an [Express](http://expressjs.com/) | ||
application: | ||
|
||
```js | ||
app.get('/auth/snapchat', | ||
passport.authenticate('snapchat')); | ||
|
||
app.get('/auth/snapchat/callback', | ||
passport.authenticate('snapchat', { failureRedirect: '/login' }), | ||
function(req, res) { | ||
// Successful authorization, redirect home. | ||
res.redirect('/'); | ||
}); | ||
``` | ||
|
||
## Examples | ||
|
||
Developers using the popular [Express](http://expressjs.com/) web framework can | ||
refer to an [example](https://github.com/Snapchat/express-4.x-passport-snapchat-example) | ||
as a starting point for their own web applications. | ||
|
||
## FAQ | ||
|
||
##### How do I ask a user for additional permissions? | ||
|
||
If you need additional permissions from the user, the permissions can be | ||
requested via the `scope` option to `passport.authenticate()`. | ||
|
||
```js | ||
app.get('/auth/snapchat', | ||
passport.authenticate('snapchat', { scope: ['user.display_name', 'user.bitmoji.avatar'] })); | ||
``` | ||
|
||
Refer to [permissions with Snapchat Login](https://docs.snapchat.com/docs/login-kit/) | ||
for further details. | ||
|
||
##### How do I obtain a user profile with specific fields? | ||
|
||
The Snapchat profile contains information about a user. By default, | ||
NO fields in a profile are returned. The fields needed by an application | ||
can be indicated by setting the `profileFields` option. | ||
|
||
```js | ||
new SnapchatStrategy({ | ||
clientID: snapchat_APP_ID, | ||
clientSecret: snapchat_APP_SECRET, | ||
callbackURL: "http://localhost:3000/auth/snapchat/callback", | ||
profileFields: ['id', 'displayName', 'bitmoji'] | ||
}), ...) | ||
``` | ||
|
||
Refer to the [Login Kit](https://docs.snapchat.com/docs/login-kit) | ||
section of the docs for the complete set of available fields. | ||
|
||
## Contributing | ||
|
||
#### Tests | ||
|
||
The test suite is located in the `test/` directory. All new features are | ||
expected to have corresponding test cases. Ensure that the complete test suite | ||
passes by executing: | ||
|
||
```bash | ||
$ npm test | ||
``` | ||
|
||
## License | ||
|
||
[The MIT License](http://opensource.org/licenses/MIT) | ||
|
||
Copyright (c) 2018 Snap Inc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
typedoc \ | ||
--includeDeclarations \ | ||
--excludeExternals \ | ||
--excludePrivate \ | ||
--excludeProtected \ | ||
--module commonjs \ | ||
--target ES5 \ | ||
--tsconfig tsconfig.docs.json \ | ||
--mode file \ | ||
--theme minimal \ | ||
--name passport-snapchat \ | ||
--readme README.md \ | ||
--sourcefile-url-prefix "https://github.com/Snapchat/passport-snapchat" \ | ||
--out docs src \ |
Oops, something went wrong.