7even / vkontakte_api

Ruby-адаптер для ВКонтакте API
http://7even.github.com/vkontakte_api
MIT License
283 stars 68 forks source link

Accessing API as app server #13

Closed oleksiipysanko closed 11 years ago

oleksiipysanko commented 11 years ago

I've trying to execute VK Api methods without user. So, I get an access token and all works fine. But when I try to execute one of the methods(users.get or wall.get), I get an error. Here is example:

1.9.3p125 :001 > token=VkWrapper.get_token => "d7ff51c9d7ff51c9d74d0f9364d7cb5f05dd7ffd7ff51c986e0d797d70740239e08994e" 1.9.3p125 :002 > vk = VkontakteApi::Client.new(token) => #<VkontakteApi::Client:0x00000002dc1818 @token="d7ff51c9d7ff51c9d74d0f9364d7cb5f05dd7ffd7ff51c986e0d797d70740239e08994e"> 1.9.3p125 :003 > user = vk.users.get(uid: '6113239').first VkontakteApi::Error: VkontakteApi::Error from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/vkontakte_api-1.1/lib/vkontakte_api/result.rb:31:in extract_result' from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/vkontakte_api-1.1/lib/vkontakte_api/result.rb:14:inprocess' from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/vkontakte_api-1.1/lib/vkontakte_api/method.rb:14:in call' from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/vkontakte_api-1.1/lib/vkontakte_api/resolver.rb:16:inmethod_missing' from (irb):3 from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in start' from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.11/lib/rails/commands/console.rb:8:instart' from /home/alex/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.11/lib/rails/commands.rb:41:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `

'

7even commented 11 years ago

Reproducing the issue brings this error:

VkontakteApi::Error: VKontakte returned an error 5: 'User authorization failed: method is unavailable with server auth.' after calling method 'users.get' with parameters {"uid"=>"6113239"}.

So basically you can't call users.get with :app_server authorization type, you need :site or :client type for that.

oleksiipysanko commented 11 years ago

Thank's, you've saved me a lot of time!