0.0.1 • Published 9 years ago
apollo-accounts-server v0.0.1
Accounts for Apollo Server
Install
npm i -S apollo-accounts-server
npm i -S apollo-accounts-knexjs # If you're using Postgres, MSSQL, MySQL, MariaDB, SQLite3, or Oracle
npm i -S apollo-accounts-mongoose # If you're using MongoExamples
Express
Supported databases
You'll need to install a package based on the type of database you're using. This package defines a schema and implements functions for reading and writing user account data.
- Postgres, MSSQL, MySQL, MariaDB, SQLite3, and Oracle - apollo-accounts-knexjs
- Mongo - apollo-accounts-mongoose
npm i -S apollo-accounts-knexjs # For SQL
npm i -S apollo-accounts-mongoose # For MongoConfiguration
Underneath the covers apollo-accounts-server uses Grant to handle signing in with different providers. It also adopts Grant's configuration and builds upon it with apollo-accounts-server specific options.
- server - configuration about your server
- redirectTo - route to redirect to on login
- loginWith - methods with which the user can login with, defaults to
['username', 'email'], - signupWith - methods with which the user can sign up with, defaults to
['username', 'email'], - protocol - either
httporhttps - host - your server's host name
localhost:3000|dummy.com:5000|mysite.com... - path - path prefix to use for the Grant middleware (defaults to empty string if omitted)
- callback - common callback for all providers in your config
/callback|/done... - transport - transport to use to deliver the response data in your final callback
querystring|session(defaults to querystring if omitted) - state - generate random state string on each authorization attempt
true|false(OAuth2 only, defaults to false if omitted)
- provider1 - any of Grant's supported provider
facebook|twitter...- extract - A function which fetches a unique identifier, username, and optionally a profile from the provider. It receives two arguments, an
accessTokenstring and theproviderobject containing the provider's configuration. It must return an object with keysidentifier,username, and optionallyprofile. - key -
consumer_keyorclient_idof your app - secret -
consumer_secretorclient_secretof your app - scope - array of OAuth scopes to request
- callback - specific callback to use for this provider (overrides the global one specified under the
serverkey) - custom_params - custom authorization parameters (see the Custom Parameters section)
- extract - A function which fetches a unique identifier, username, and optionally a profile from the provider. It receives two arguments, an
const config = {
server: {
secret: 'terrible secret',
redirectTo: '/home',
},
github: {
key: 'client key from github',
secret: 'client secret from github',
},
};How this package works
0.0.1
9 years ago