Authorization in Vkontakte social network as standalone/mobile application for Node.JS servers
Authorization in Vkontakte social network as standalone/mobile application. Allows you to get vk token with the help of PhantomJS headless browser.
Using vk-auth is easy enough; it accepts two parameters in it’s constructor (applicationId and required permissions) and provides single method for authorization:
var vkAuth = require('vk-auth')(123456, 'audio');
vkAuth.authorize('johndoe@example.com', 'password', function(err, tokenParams) {
//do something with access token
});
v1.0.6
v1.0.5
v1.0.4
v1.0.3
v1.0.1-1.0.2
v1.0.0
v0.0.6
v0.0.5
v0.0.4
v0.0.3
v0.0.2
v0.0.1
To get applicationId you need to create vk app here.
You can pass app permissions as a string or array e.g.
var permissions = 'friends,video,offline';
var anotherPermissons = [
'wall',
'friends'
];
To get more information about available permissions visit Application Access Permissions page
Login - user’s email or phone number
Password - user’s password
Callback(err, tokenParams) - accepts two parameters - error and token parameters
You can subscribe to events emitted by authorization module instead of passing callback.
There are two events available:
“auth” - Authorization succeed
“error” - Error happened during authorization
Example:
var vkAuth = require('vk-auth')(123456, 'audio');
vkAuth.authorize('johndoe@example.com', 'password');
vkAuth.on('error', function(err) {
console.log(err);
});
vkAuth.on('auth', function(tokenParams) {
//do something with token parameters
})
Here is an example of received token parameters:
{
access_token: 801edadc2f0d1898676e2804ec50b9990801dcd3fd5e9bc197898c19b9d796596d79c03278489f3e88
expires_in: 86400
user_id: 49923862
}
To read more about this parameters go to Client Application Authorization page.
Feel free to ask questions and post ideas, as well as send pull requests.
If you want to support me, leave tip at Gratipay: