Vkontakte OAuth for
micro
.
now
.https://your-now-url.now.sh
that was generated as the baseURL & authorized redirectURL in your VK Application Dashboard.https://your-now-url.now.sh/auth/vkontakte
.You may also choose to run the example locally by cloning the repository & following these instructions.
npm install --save micro microauth-vkontakte
# or
yarn add micro microauth-vkontakte
const { send } = require('micro')
const microAuthVkontakte = require('microauth-vkontakte')
const options = {
clientId: 'YOUR VK APP ID',
clientSecret: 'YOUR VK APP SECRET',
fields: ['city', 'country', 'photo_200'],
redirectUrl: 'http://localhost:3000/auth/vkontatke/callback',
scope: ['friends', 'photos']
}
const vkontakteAuth = microAuthVkontakte(options)
module.exports = vkontakteAuth(async (req, res, auth) => {
if (!auth) return send(res, 404, 'Not Found')
if (auth.err) {
console.log(auth.err)
return send(res, 403, 'Forbidden')
}
return `Hello ${auth.info.first_name}`
})
The options object you pass to microAuthVkontakte
has predefined defaults in place. Should you not provide the 3 required parameters clientId
, clientSecret
, & redirectUrl
you will be informed in your terminal with an error message of what you are missing. The other default parameters as well as documentation for valid values accepted by the Vkontakte API can be found here.
It is your responsibility as a developer to not expose your secure data publicly! Please use such packages as dotenv
or dotenv-safe
to manage your secure data through environment variables.
Please read the CONTRIBUTING.md
npm test
# or
yarn test
To verify the package is in working order on your local machine you can run the below script. It will produces ./package
. You can then go into the ./example
directory and change the location in which microauth-vkontakte
is being used:
const microAuthVkontakte = require('../package/src')
npm start package
# or
yarn start package
Cody Brunner 💻 📖 💡 ⚠️ |
---|
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!