https://github.com/microauth/microauth-vkontakte
Vkontakte OAuth for micro.
https://github.com/microauth/microauth-vkontakte
Last synced: about 1 month ago
JSON representation
Vkontakte OAuth for micro.
- Host: GitHub
- URL: https://github.com/microauth/microauth-vkontakte
- Owner: microauth
- License: mit
- Created: 2017-08-22T20:45:40.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2026-01-28T21:50:03.000Z (4 months ago)
- Last Synced: 2026-03-05T15:18:43.868Z (3 months ago)
- Language: JavaScript
- Size: 3.87 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 31
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# microauth-vkontakte :closed_lock_with_key:
[](https://www.npmjs.com/package/microauth-vkontakte)
[](https://www.npmjs.com/package/microauth-vkontakte)
[](https://www.npmjs.com/package/microauth-vkontakte)
[](https://circleci.com/gh/microauth/microauth-vkontakte)
[](https://codecov.io/gh/microauth/microauth-vkontakte)
[](https://greenkeeper.io/)
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/microauth/microauth-vkontakte/pulls)
[](https://github.com/semantic-release/semantic-release)
[](#contributors)
[](https://github.com/prettier/prettier)
[](https://github.com/kentcdodds/nps)
[](https://github.com/EQuimper/eslint-config-equimper)
> Vkontakte OAuth for [`micro`](https://github.com/zeit/micro).
## Running the example
1. Setup an account with [Zeit](https://zeit.co).
2. Go to [Vkontakte](https://vk.com/editapp?act=create) & create an app to get your credentials.
3. Click the button below and add those credentials along with your Zeit API Token to the environment variables requested by `now`.
4. Add the `https://your-now-url.now.sh` that was generated as the baseURL & authorized redirectURL in your VK Application Dashboard.
5. Use a browser or a tool like [Postman](https://www.getpostman.com/postman) and visit: `https://your-now-url.now.sh/auth/vkontakte`.
[](https://deploy.now.sh/?repo=https://github.com/microauth/microauth-vkontakte/tree/master/example&env=VK_APP_ID&env=VK_APP_SECRET)
You may also choose to run the example locally by cloning the repository & following these [instructions](https://github.com/microauth/microauth-vkontakte/example).
## Usage
```sh
npm install --save micro microauth-vkontakte
# or
yarn add micro microauth-vkontakte
```
```js
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}`
})
```
## Default Parameters
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](https://github.com/microauth/microauth-vkontakte/blob/master/src/utils/vkOpts.js).
## Security
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.
## Contributing
Please read the [CONTRIBUTING.md](https://github.com/microauth/microauth-vkontakte/blob/master/CONTRIBUTING.md)
## Development & Testing
```sh
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:
```js
const microAuthVkontakte = require('../package/src')
```
```sh
npm start package
# or
yarn start package
```
## License
[MIT](https://github.com/microauth/microauth-vkontakte/blob/master/LICENSE)
## Contributors
| [
Cody Brunner](https://rcws-development.com/)
[💻](https://github.com/microauth/microauth-vkontakte/commits?author=rockchalkwushock "Code") [📖](https://github.com/microauth/microauth-vkontakte/commits?author=rockchalkwushock "Documentation") [💡](#example-rockchalkwushock "Examples") [⚠️](https://github.com/microauth/microauth-vkontakte/commits?author=rockchalkwushock "Tests") |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!