🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

vk-dirty-api

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vk-dirty-api

Wrapper for using VK API within your project as a Standalone application

3.0.2
latest
Source
npm
Version published
Weekly downloads
1
-92.31%
Maintainers
1
Weekly downloads
 
Created
Source

vk-dirty-api

Build Status Test Coverage Dependency Status JavaScript Style Guide

VK API for Node.js with authentication using login and password (the dirty way)

Sometimes it is needed to use VK API directly from the Node app, however, using either signing requests or OAuth allows access only to server-side methods. In order to 'overcome' this limitation, this dirty if you know what I mean way of getting access_token for VK API was developed

Installation

$ npm install vk-dirty-api --save

Usage

Super simple to use

const vk = require('vk-dirty-api')

const credentials = {
  client_id: 0, // application ID (available in app settings at https://vk.com/apps?act=manage)
  login: 'user@example.com',
  pass: 'your_super_secret_password',
  phone: '+74951234567',
  tokenStorage: new vk.TokenStorage() // built-in token storage that stores retrieved access token in file for
                                      // further use
}

/**
 * Retrieve access_token using credentials defined above
 */
vk.token(credentials)
  .then(token => {
    console.log(`Successfully authenticated (access_token: ${token})`)

    /**
     * Use built-in API call helper
     */
    const api = vk.api(token)

    /**
     * Request current account info
     */
    return api('account.getInfo', { fields: 'country' })
      .then(info => console.log('Account info', info))
      .catch(err => console.error('Unable to complete API request', err))
  })
  .catch(err => console.error('Unable to authenticate', err))

Keywords

vk

FAQs

Package last updated on 11 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts