57uff3r / nodejs-vksdk

NodeJS SDK for vk.com
201 stars 82 forks source link

How i can get access_token for using wall.post method #14

Closed nazargulov closed 8 years ago

nazargulov commented 9 years ago

I'm trying to call https://oauth.vk.com/authorize?client_id=4822241&scope=wall,offline&redirect_uri=http://oauth.vk.com/blank.html&display=page&response_type=token And copy the acces_token from url But, if call a) https://api.vk.com/method/wall.post?owner_id=36299915&message=1&access_token=COPYPASTE_TOKEN b) vk.setToken(accessToken); vk.request('wall.post', { 'owner_id': userId, 'message': '1' }, function(_o) { console.log(_o); });

a get error: 15: Access denied: no access to call this method

57uff3r commented 9 years ago

It's not allowed for wall.post to do posts from server side.

https://vk.com/dev/wall.post

Alex0007 commented 9 years ago

You can use phantomjs or simple http requests, to authorize and get token.

Then simply add access_token to vk.request params object like:

vk.request('messages.send', {
    user_id: id,
    message: message,
    access_token: token
}, function (_o) {})

Note, that your app must be "Standalone app" in this case