Giter Club home page Giter Club logo

vk-auth's Introduction

vk-auth

Authorization in Vkontakte social network as standalone/mobile application. Allows you to get vk token with the help of PhantomJS headless browser.

npm

NPM Version NPM Downloads

Issues

Tasks in Ready Tasks in Progress

Build information

Build Status Coverage Status

Example

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('[email protected]', 'password', function(err, tokenParams) {
    //do something with access token
});

Changelog

v1.0.6

  • Issue with markup change on permissions page fixed
  • Dependencies are updated

v1.0.5

  • PhantomJS was updated to version 2

v1.0.4

  • Issue with form submit fixed

v1.0.3

  • Updates in VK URLs (thanks to Dmitriy)
  • Error messages do not contain new line symbol

v1.0.1-1.0.2

  • Fixes in readme

v1.0.0

  • First release
  • Small code improvements
  • Tests for node.js part of module
  • Daily build to check that module is still working

v0.0.6

  • 'error' event is not emited when no listeners attached and callback is present

v0.0.5

  • Should work again after VK urls updates
  • Error for wrong credentials is now displayed again

v0.0.4

  • PhantomJS is now started by 'execFile' command instead of 'exec'

v0.0.3

  • Events added

v0.0.2

  • Result format changed to look the same way as vk response
  • All errors including VK and wrong credentials errors are now passed through 'err' callback parameters

v0.0.1

  • Initial module version

Constructor parameters

require('vk-auth')(applicationId, permissions);

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

Method parameters

vkAuth.authorize(login, password, callback)

Login - user's email or phone number

Password - user's password

Callback(err, tokenParams) - accepts two parameters - error and token parameters

Events

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('[email protected]', 'password');

vkAuth.on('error', function(err) {
    console.log(err);
});

vkAuth.on('auth', function(tokenParams) {
    //do something with token parameters
})

Token

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.

Сontribution

Feel free to ask questions and post ideas, as well as send pull requests. If you want to support me, leave tip at Gratipay: Gratipay

License: MIT

vk-auth's People

Contributors

darkxahtep avatar iamnoturkitty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vk-auth's Issues

Revisit VK urls

Revisit urls in phantom script. switch to noJS auth page version if possible

Login or password is often incorrect

Suddenly I began to recieve an error that my login or password is incorrect, meanwhile it works fine on vk.com. Is it possible that vk.com changed HTML form? Can you find it out, please?
P.S. Probably I was blocked by IP :)

Request timeout error

Запускаю скрипт и через 3-4 секунды вываливается ошибка

[Error: Request timeout error]

Вот мой файл vk.js

var vkAuth = require('vk-auth')(5324751, 'audio');

vkAuth.authorize('+38XXXXXXXXXX', '*********');

vkAuth.on('error', function(err) {
    console.log(err);
});

vkAuth.on('auth', function(tokenParams) {
    console.log(tokenParams);
    //do something with token parameters
})

Запускаю так

$ node vk.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.