Code Monkey home page Code Monkey logo

omniauth-vkontakte's Introduction

OmniAuth VKontakte

Ruby Codacy Badge Gem Version Maintainability

This is the unofficial OmniAuth strategy for authenticating to VKontakte via OAuth. To use it, you'll need to sign up for an OAuth2 Application ID and Secret on the Vkontakte Developers Page.

SWUbanner

Installing

Add to your Gemfile:

gem 'omniauth-vkontakte'

Then bundle install

Usage

OmniAuth::Strategies::Vkontakte is simply a Rack middleware.

Here's a quick example, adding the middleware to a Rails app in config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :vkontakte, ENV['VK_API_ID'], ENV['VK_API_SECRET']
end

See the example Sinatra app.

Configuring

You can configure several options, which you pass in to the provider method via a Hash:

  • scope: a comma-separated list of access permissions you want to request from the user. Read the Vkontakte docs for more details
  • display: the display context to show the authentication page. Valid options include page, popup and mobile.
  • lang: specifies the language. Optional options include ru, ua, be, en, es, fi, de, it.
  • image_size: defines the size of the user's image. Valid options include mini(50x50), bigger(100x100), bigger_x2(200x200), original(200x*) and original_x2(400x*). Default is mini.
  • info_fields: specify which fields should be added to AuthHash when getting the user's info. Value should be a comma-separated string as per http://vk.com/dev/fields.
  • redirect_url: URL where code will be passed. This URL shall be a part of the domain specified in application settings http://vk.com/dev/auth_sites.
  • https: 1 - allows you to receive https links to photos and other media. 0 - return an http links (the default).

Here's an example of a possible configuration:

use OmniAuth::Builder do
  provider :vkontakte, ENV['VKONTAKTE_KEY'], ENV['VKONTAKTE_SECRET'],
           scope: 'friends,audio,photos',
           display: 'popup',
           lang: 'en',
           https: 1,
           image_size: 'original'
end

Authentication Hash

Here's an example Auth Hash available in request.env['omniauth.auth']:

{"provider"=>"vkontakte",
 "uid"=>"1",
 "info"=>
  {"name"=>"Павел Дуров",
   "nickname"=>"",
   "first_name"=>"Павел",
   "last_name"=>"Дуров",
   "image"=>"http://cs7001.vk.me/c7003/v7003079/374b/53lwetwOxD8.jpg",
   "location"=>"Росiя, Санкт-Петербург",
   "urls"=>{"Vkontakte"=>"http://vk.com/durov"}},
 "credentials"=>
  {"token"=>
    "187041a618229fdaf16613e96e1caabc1e86e46bbfad228de41520e63fe45873684c365a14417289599f3",
   "expires_at"=>1381826003,
   "expires"=>true},
 "extra"=>
  {"raw_info"=>
    {"id"=>1,
     "first_name"=>"Павел",
     "last_name"=>"Дуров",
     "sex"=>2,
     "nickname"=>"",
     "screen_name"=>"durov",
     "bdate"=>"10.10.1984",
     "city"=>{"id"=>2, "title"=>"Санкт-Петербург"},
     "country"=>{"id"=>1, "title"=>"Росiя"},
     "photo"=>"http://cs7001.vk.me/c7003/v7003079/374b/53lwetwOxD8.jpg",
     "photo_big"=>"http://cs7001.vk.me/c7003/v7003736/3a08/mEqSflTauxA.jpg",
     "online"=>1,
     "online_app"=>"3140623",
     "online_mobile"=>1}}}

The precise information available may depend on the permissions which you request.

Supported Rubies

Tested with the following Ruby versions:

  • Ruby MRI (2.7.0+)
  • JRuby (9.3.0+)

Contributing

  1. Fork it (https://github.com/mamantoha/omniauth-vkontakte/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

Copyright: 2011-2023 Anton Maminov ([email protected])

This library is distributed under the MIT license. Please see the LICENSE file.

omniauth-vkontakte's People

Contributors

ajaxy avatar artofhuman avatar atipugin avatar codacy-badger avatar darthsim avatar dependabot[bot] avatar depfu[bot] avatar dmeremyanin avatar galetahub avatar jekhor avatar jughead avatar kaine avatar kein1945 avatar ksevelyar avatar mamantoha avatar mendab1e avatar merqlove avatar ngoral avatar rootooz avatar shaggyone avatar thorn avatar torbjon avatar

Stargazers

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

Watchers

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

omniauth-vkontakte's Issues

NoMethodError: undefined method `[]' for nil:NilClass

С каждым днем все интереснее, пользователей правда пугает регистрация без вконтакте.
Выскакивает после нажатия на "разрешить" и редирект на приложение.

…h-vkontakte-1.1.2/lib/omniauth/strategies/vkontakte.rb: 37:in block in <class:Vkontakte>' …uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 102:ininstance_eval'
…uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 102:in block in compile_stack' …uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 101:ineach'
…uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 101:in inject' …uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 101:incompile_stack'
…uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 315:in info' …uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 328:inauth_hash'
…uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 355:in callback_phase' …mniauth-oauth2-1.1.1/lib/omniauth/strategies/oauth2.rb: 77:incallback_phase'
…uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 219:in callback_call' …uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 175:incall!'
…uby/1.9.1/gems/omniauth-1.1.1/lib/omniauth/strategy.rb: 157:in call' …ations-3.1.4/lib/client_side_validations/middleware.rb: 18:incall'
…ems/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb: 35:in block in call' …ems/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb: 34:incatch'
…ems/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb: 34:in call' …hared/gems/ruby/1.9.1/gems/rack-1.4.1/lib/rack/etag.rb: 23:incall'
…/ruby/1.9.1/gems/rack-1.4.1/lib/rack/conditionalget.rb: 25:in call' …/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb: 205:incontext'
…/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb: 200:in call' …/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb: 21:incall'
…ed/gems/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb: 17:in call' …hared/gems/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb: 15:incall'
…by/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb: 136:in forward' …by/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb: 245:infetch'
…by/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb: 185:in lookup' …by/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb: 66:incall!'
…by/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb: 51:in call' …by/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb: 535:inprocess_client'
…by/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb: 610:in worker_loop' …by/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb: 491:inspawn_missing_workers'
…by/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb: 502:in maintain_worker_count' …by/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb: 276:injoin'

NoMethodError (undefined method `first' for nil:NilClass): lib/omniauth/strategies/vkontakte.rb:111:in `get_city'

Ошибка при запросе /method/getCities

NoMethodError (undefined method first' for nil:NilClass): omniauth-vkontakte (1.1.1) lib/omniauth/strategies/vkontakte.rb:111:inget_city'
omniauth-vkontakte (1.1.1) lib/omniauth/strategies/vkontakte.rb:118:in location' omniauth-vkontakte (1.1.1) lib/omniauth/strategies/vkontakte.rb:42:inblock in class:Vkontakte'
omniauth (1.1.1) lib/omniauth/strategy.rb:102:in instance_eval' omniauth (1.1.1) lib/omniauth/strategy.rb:102:inblock in compile_stack'
omniauth (1.1.1) lib/omniauth/strategy.rb:101:in each' omniauth (1.1.1) lib/omniauth/strategy.rb:101:ininject'
omniauth (1.1.1) lib/omniauth/strategy.rb:101:in compile_stack' (eval):7:ininfo_stack'
omniauth (1.1.1) lib/omniauth/strategy.rb:315:in info' omniauth (1.1.1) lib/omniauth/strategy.rb:328:inauth_hash'
omniauth (1.1.1) lib/omniauth/strategy.rb:355:in callback_phase' omniauth-oauth2 (1.1.1) lib/omniauth/strategies/oauth2.rb:77:incallback_phase'
omniauth (1.1.1) lib/omniauth/strategy.rb:219:in callback_call' omniauth (1.1.1) lib/omniauth/strategy.rb:175:incall!'
omniauth (1.1.1) lib/omniauth/strategy.rb:157:in call' warden (1.2.1) lib/warden/manager.rb:35:inblock in call'
warden (1.2.1) lib/warden/manager.rb:34:in catch' warden (1.2.1) lib/warden/manager.rb:34:incall'

Обращение ajax-ом к :user_omniauth_callback_path провоцирует ошибку invalid_credentials

Лог ошибки:
(vkontakte) Callback phase initiated.
(vkontakte) Authentication failure! invalid_credentials: OAuth2::Error, invalid_grant: Code is invalid or expired.
{"error":"invalid_grant","error_description":"Code is invalid or expired."}

Точно такая же ошибка была с omniauth-facebook 1.4.1, но если откатить до 1.4.0 все работает отлично:
(facebook) Callback phase initiated.
Started GET "/users/auth/facebook/callback" for 127.0.0.1 at 2013-04-18 18:33:56 +0400
Processing by Users::OmniauthCallbacksController#facebook as /
User Load (142.3ms) SELECT "users".* FROM "users" WHERE "users"."url" = 'http://www.facebook.com/...' LIMIT 1

Я пока сам не нашел в чем решающая разница между 1.4.1 и 1.4.0

Add Rubocop

Try to add quality code inspection to Travis CI

Error on callback redirect

An error occured after redirect on callback controller. Exeption notification says:
A NoMethodError occurred in #:
undefined method `[]' for nil:NilClass

in logs:
NoMethodError (undefined method []' for nil:NilClass): omniauth-vkontakte (1.3.1) lib/omniauth/strategies/vkontakte.rb:29:inblock in class:Vkontakte'
omniauth (1.1.4) lib/omniauth/strategy.rb:106:in instance_eval' omniauth (1.1.4) lib/omniauth/strategy.rb:106:inblock in compile_stack'
omniauth (1.1.4) lib/omniauth/strategy.rb:105:in each' omniauth (1.1.4) lib/omniauth/strategy.rb:105:ininject'
omniauth (1.1.4) lib/omniauth/strategy.rb:105:in compile_stack' (eval):7:inuid_stack'
omniauth (1.1.4) lib/omniauth/strategy.rb:318:in uid' omniauth (1.1.4) lib/omniauth/strategy.rb:334:inauth_hash'
omniauth (1.1.4) lib/omniauth/strategy.rb:362:in callback_phase' omniauth-oauth2 (1.1.1) lib/omniauth/strategies/oauth2.rb:77:incallback_phase'
omniauth (1.1.4) lib/omniauth/strategy.rb:226:in callback_call' omniauth (1.1.4) lib/omniauth/strategy.rb:182:incall!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in call' omniauth (1.1.4) lib/omniauth/strategy.rb:184:incall!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in call' newrelic_rpm (3.7.2.195) lib/new_relic/rack/error_collector.rb:55:incall'
newrelic_rpm (3.7.2.195) lib/new_relic/rack/agent_hooks.rb:32:in call' newrelic_rpm (3.7.2.195) lib/new_relic/rack/browser_monitoring.rb:27:incall'
exception_notification (4.0.1) lib/exception_notification/rack.rb:28:in call' /var/www/loveeatwith/shared/bundle/ruby/2.0.0/bundler/gems/client_side_validations-9461cb92e1df/lib/client_side_validations/middleware.rb:21:incall'
warden (1.2.3) lib/warden/manager.rb:35:in block in call' warden (1.2.3) lib/warden/manager.rb:34:incatch'
warden (1.2.3) lib/warden/manager.rb:34:in call' rack (1.5.2) lib/rack/etag.rb:23:incall'
rack (1.5.2) lib/rack/conditionalget.rb:25:in call' rack (1.5.2) lib/rack/head.rb:11:incall'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in call' actionpack (4.0.2) lib/action_dispatch/middleware/params_parser.rb:27:incall'
actionpack (4.0.2) lib/action_dispatch/middleware/flash.rb:241:in call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.0.2) lib/action_dispatch/middleware/cookies.rb:486:incall'
activerecord (4.0.2) lib/active_record/query_cache.rb:36:in call' activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:incall'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:in block in call' activesupport (4.0.2) lib/active_support/callbacks.rb:373:in_run__1289984297035080464__call__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in run_callbacks' actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:incall'
actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in call' actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.0.2) lib/rails/rack/logger.rb:38:incall_app'
railties (4.0.2) lib/rails/rack/logger.rb:20:in block in call' activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:inblock in tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in tagged' activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:intagged'
railties (4.0.2) lib/rails/rack/logger.rb:20:in call' actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.5.2) lib/rack/methodoverride.rb:21:in call' rack (1.5.2) lib/rack/runtime.rb:17:incall'
activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in call' rack (1.5.2) lib/rack/sendfile.rb:112:incall'
railties (4.0.2) lib/rails/engine.rb:511:in call' railties (4.0.2) lib/rails/application.rb:97:incall'
unicorn (4.7.0) lib/unicorn/http_server.rb:580:in process_client' unicorn (4.7.0) lib/unicorn/http_server.rb:660:inworker_loop'
newrelic_rpm (3.7.2.195) lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:22:in call' newrelic_rpm (3.7.2.195) lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:22:inblock (4 levels) in <top (required)>'
unicorn (4.7.0) lib/unicorn/http_server.rb:527:in spawn_missing_workers' unicorn (4.7.0) lib/unicorn/http_server.rb:153:instart'
unicorn (4.7.0) bin/unicorn_rails:209:in <top (required)>' /var/www/loveeatwith/shared/bundle/ruby/2.0.0/bin/unicorn_rails:23:inload'
/var/www/loveeatwith/shared/bundle/ruby/2.0.0/bin/unicorn_rails:23:in `

'

иногда выскакивает NoRawData

использую:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :vkontakte, ENV['API_ID'], ENV['API_SECRET'],
           scope: 'friends',
           lang: 'ru',
           https: 1,
           image_size: 'original'
end

Работает безупречно во всех случаев кроме нескольких профайлов. Интересно что другие интеграции с LinkedIn например выдают {} что бы пользователь продолжил регистрацию.

Могли бы объяснить почему решили остановить пользователя от дальнейшей регистрации с помощью метода fail!

И вообще в каких случаях может Контакт возвращать пустой ответ?

Is expires_at is working?

After authorizing i get

credentials: !ruby/hash:Hashie::Mash
  token: blah
  expires_at: 1368545534
  expires: true

expires_at is coming back with basically Time.now of the request

irb(main):009:0> Time.at 1368545534
=> 2013-05-14 15:32:14 +0000

Работа с development

Создал приложение, в Gemfile: gem 'omniauth-vkontakte'.

Настроил omniauth.rb, в настройке приложения на сайте вк указал:
адрес сайта: http://localhost:3000/
базовый домен: localhost

Всё бы ничего, но когда я делаю link_to "регистрируйтесь вк", "/auth/vkontakte", мне вылезает вот это:

{"error":"invalid_request","error_description":"redirect_uri has wrong domain, check application settings"}

Строка логина:
https://oauth.vk.com/authorize?response_type=code&client_id=***&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fvkontakte%2Fcallback

А для facebook и twitter всё работает. В чём дело?

undefined method `first' for nil:NilClass (2)

vendor/bundle/ruby/1.9.1/gems/omniauth-vkontakte-1.1.1/lib/omniauth/strategies/vkontakte.rb:63:in `raw_info'

Проблема теперь другая. Вконтакт с тукеном теперь не отдает инфу на метод getProfiles.
Ничего не смог найти по этому поводу, в коде вроде все ОК (но проверка parsed["response"] на nil не помешала бы).
Может Вконтакт теперь хочет дополнительные параметры для этого метода?

{"error":"invalid_client","error_description":"client_id is undefined"}

В геме oauth2 поменялась auth_scheme по умолчанию с request_body на basic_auth.
Если у вас возникает ошибка client_id is undefined, нужно добавить настройку client_options - auth_scheme

config.omniauth :vkontakte,
  ENV['VK_API_ID'], ENV['VK_API_SECRET'],
  client_options: {
    auth_scheme: 'request_body'
  }

Такая же проблема в геме omniauth-apple - nhosoya/omniauth-apple#85

client_id is incorrect

Hi, your strategies is:

require 'omniauth/strategies/oauth2'

module OmniAuth
  module Strategies
    
   # Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve
    # basic user information.
    # documentation available here:
    # http://vk.com/dev/authentication
    #
    # @example Basic Usage
    #     use OmniAuth::Strategies::Vkontakte, 'API Key', 'Secret Key'
    #
    class Vkontakte < OmniAuth::Strategies::OAuth2
      class NoRawData < StandardError; end

API_VERSION = '5.8'

but in app have
error | "invalid_client" error_description | "client_id is incorrect"

По какой-то причине виснет в ожидании загрузки

В приложении используется авторизация twitter, facebook, odnoklassniki, все они работают нормально, проблема именно с vkontakte

после нажатия на кнопку подтвердить в логах сервера появляется следующее

Started GET "/user/auth/vkontakte/callback?code=be613f43c1a4879166&state=5d078f6c6737f048775ffc710270c0aed41c66468ffa175d" for 127.0.0.1 at 2012-12-11 04:33:12 +0400

и на этом все, дальше ни чего не происходит
может в курсе из-за чего такое может быть?

Offline Access

Adding { scope: 'offline' } doesn't seem to work when requesting tokens that don't expire. I still get an expiration time and true for expires.

"credentials"=>{"token"=>"some_token", "expires_at"=>1482941649, "expires"=>true},

And when I do authorize I see that it's asking for offline access but seems to have an expiration still.

Пустой request.env['omniauth.auth']

Доброго времени суток.
Использую rails 5.1.4 без devise. Режим config.api_only не включен.

В конфиге:

provider :vkontakte, ENV['OAUTH_APP_ID'], ENV['OAUTH_VK_SECRET'],
    scope: 'email, photos',
    image_size: 'original',
    redirect_url: 'http://localhost:3000/api/v1/oauth/callback',
    display: 'page',
    lang: 'ru',
    https: 1

Дергаю get /auth/vkontakte - происходит корректный запрос к vk - корректный редирект на redirect_url, но в экшене коллбека request.env['omniauth.auth'] == nil.
Через https://github.com/mkdynamic/omniauth-facebook все работает корректно.

Не подскажете, в чем может быть проблема?

UPD расставил брекпоинты дебаггера здесь: https://github.com/omniauth/omniauth/blob/master/lib/omniauth/strategy.rb, ни в одну не попало. То есть вообще не отрабатывает

Нет email адреса

Сейчас появилась возможность получать емейл, но он он не приходит в ответе, хотя юзер дает разрешение на это.

redirect_uri is invalid, please pass same redirect_uri, you used in authorize method

I can't make login via Devise
config.omniauth :vkontakte, 'APP_ID', 'APP_SECRET', scope: 'friends,audio,email,offline,video'
url: localhost:3000/users/auth/vkontakte
And I get an error

I, [2015-11-04T13:32:16.541188 #13163]  INFO -- omniauth: (vkontakte) Callback phase initiated.
E, [2015-11-04T13:32:17.002804 #13163] ERROR -- omniauth: (vkontakte) Authentication failure! invalid_credentials: OAuth2::Error, invalid_grant: redirect_uri is invalid, please pass same redirect_uri, you used in authorize method.
{"error":"invalid_grant","error_description":"redirect_uri is invalid, please pass same redirect_uri, you used in authorize method."}
Processing by OmniauthCallbacksController#failure as HTML

фамилия и имя возвращаются транслитом

Метод API users.get() возвращает фамилию и имя транслитом, если физически сервер расположен например в штатах.
Вроде это решается указанием нужного заголовка 'Accept-Language'.
Как его можно указать? или эта проблема решается подругому?

Работает?

Вчера всё работало, сегодня выдает /auth/failure?message=invalid_credentials
что с этим делать?)

Unneeded API calls

I faced a problem that VK authentication was too slow on my production server. Started digging. And found, besides that there was configured slow DNS-server (solved with namebench and dnsmasq), that your gem makes 3 extra calls to VK API, querying user's data. However, these data are only necessary for creating user records for the first time. Could you make these data be queryied only by explicit calls of auth hash properties?

Results of rack-mini-profiler gem:

GET http://127.0.0.1:3000/users/auth/vkontakt...     27.9   +0.0    
  Net::HTTP POST /access_token   60.8   +15.0   
   Net::HTTP POST /access_token  25.6   +76.0   
  Net::HTTP GET /method/users.get?access_token=...   57.0   +103.0  
   Net::HTTP GET /method/users.get?access_token=...  30.5   +160.0  
  Net::HTTP GET /method/database.getCountriesBy...   65.1   +192.0  
   Net::HTTP GET /method/database.getCountriesBy...  23.4   +257.0  
  Net::HTTP GET /method/database.getCitiesById?...   63.9   +282.0  
   Net::HTTP GET /method/database.getCitiesById?...  33.6   +346.0

Работа в develompent

Привет.

Я новичок и мне достался проект с твоим гемом. Разработчик предыдущий вел разработку прямо с продакшен-сервера и поэтому, видимо, не сталкивался с той проблемой, с которой столкнулся я, и ничем помочь мне не может. А проблема у меня такая же, как и вот в этой ветке, но у меня не получается ее решить тем способом, который там указан.

Т.е. мой продакшен работает по адресу, скажем, xyz.ru
Я иду в /etc/hosts, комментирую # 127.0.0.1 localhost и добавляю 127.0.0.1 xyz.ru
Все верно?
После этого перезагружаю систему, делаю rails s и получаю
.rbenv/versions/2.2.2/lib/ruby/2.2.0/socket.rb:232:in 'getaddrinfo': getaddrinfo: Name or service not known (SocketError)

Убиваю процесс и запускаю сервер заново. Он запускается.
=> Booting WEBrick => Rails 4.2.1 application starting in development on http://localhost:3000

Но при этом в ответ на /auth/vkontakte, мне снова вылезает вот это:
{"error":"invalid_request","error_description":"redirect_uri has wrong domain, check application settings"} и запрос снова содержит redirect_uri=http%3A%2F%2Flocalhost%3A3000

Там было написано еще запустить сервер на 80-м порту, но я не могу это сделать, тк в ответ на rails s -p 80 получаю Permission denied - bind(2) for 127.0.0.1:80 (Errno::EACCES)

Буду очень благодарен за помощь, самостоятельно разобраться не получается. Готов предоставить любую неоходимую информацию.

Работает ли данный модуль со Standalone приложениями?

При авторизации он хочет сделать редирект на URI. В VK у меня создано Standalone приложение, а работать пытаюсь с локально развернутого веб приложения, у которого URI это http://192.168.56.101:3000. Соответственно VK выдает мне

{"error":"invalid_request","error_description":"redirect_uri is incorrect, check application domain in the settings page"}

Могу ли я авторизоваться к локальному веб приложению? И как мне его тогда регистрировать в VK, как Standalone или как веб-сайт?

Stategy fails with omniauth 1.1

App raise "invalid credensials" when login secons time. Debugin' issue I found it depends on gem versions.
This fails:

 bundle show |grep omni
  * omniauth (1.1.0)
  * omniauth-oauth (1.0.1)
  * omniauth-oauth2 (1.1.0)
  * omniauth-vkontakte (1.0.6)

This works perfect:

bundle show |grep omni
  * omniauth (1.0.3)
  * omniauth-oauth (1.0.1)
  * omniauth-oauth2 (1.0.0)
  * omniauth-vkontakte (1.0.6)

Maybe its devise issue - I can't found it.

standalone applications should use blank.html as redirect_uri to access messages

Привет!
Настройки такие:

config.omniauth :vkontakte, Settings['vkontakte']['app_id'], Settings['vkontakte']['app_secret'], :scope => 'friends,messages' 

Что можно с этим сделать? Можно ли указать определенный redirect_uri в настройках при аутоинтификации?

Getting 502 on callback

Since few days ago, callback leads to 502, bad gateway. 1 of 10 attempts work ok, others not, Didn't touch anything, as always. Dev page says there are changes to https since november, can this be a source of problem? https://vk.com/dev/https_only

ArgumentError

Hello, I tried to use this gem but recieve error:

ArgumentError
Received wrong number of arguments. ["eRCcsdw9I5xfZLqe8V", {:authorize_url=>"http://api.vkontakte.ru/oauth/authorize", :token_url=>"https://api.vkontakte.ru/oauth/token"}]

Others strategies: facebook and twitter works fine.

How to fix it?

ERROR -- omniauth: (vkontakte) Authentication failure! csrf_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected

Guys!

I am trying to get user signed in with vkontakte using openapi as written here https://vk.com/dev/Javascript_SDK with omnioauthcallbackcontroller what gives me error ERROR -- omniauth: (vkontakte) Authentication failure! csrf_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected on callback.

Can you shed some light on what am I doing wrong? Same approach with FB and others work..

Could not authenticate you from Vkontakte because "No raw data"

Добрый день.

Установил все что нужно было, прекрасно работает на локалке с доменом localhost:3000, но при деплое на сервер вываливается ошибка.

Почему то

access_token.get('/method/users.get', :params => params).parsed["response"] 

возращает nil.

Как понять, какую ошибку возвращает VK и почему?

Спасибо.

invalid_credentials: OAuth2::Error, invalid_grant: Code is invalid or expired

Используя vkontakte openapi, делаю ajax запрос, получаю эту ошибку. При этом, когда авторизуюсь через переход по ссылки, все работает.
Мой лог:
Started GET "/users/auth/vkontakte/callback" for 127.0.0.1 at 2017-06-11 02:13:07 +0300
I, [2017-06-11T02:13:07.145807 #2678] INFO -- omniauth: (vkontakte) Callback phase initiated.
E, [2017-06-11T02:13:07.244664 #2678] ERROR -- omniauth: (vkontakte) Authentication failure! invalid_credentials: OAuth2::Error, invalid_grant: Code is invalid or expired.
{"error":"invalid_grant","error_description":"Code is invalid or expired."}

Подскажите, это у меня какие то настройки не верные, или гем не рассчитан на работу с ajax?
Если второй случай, то куда копнуть что бы добавить эту возможность?

undefined method `first' for nil:NilClass

I think today Vkontakte send another info data and it do error:

undefined method first' for nil:NilClass vendor/bundle/ruby/1.9.1/gems/omniauth-vkontakte-1.1.0/lib/omniauth/strategies/vkontakte.rb:83:inget_country'

application was deleted

Возвращает такую ошибку:

{"error":"invalid_request","error_description":"application was deleted"}

Приложения создал бувально 10 минут назад. Домен добавил в /etc/hosts.
Запускаю на 80-ом порту(rvmsudo rails server -p 80)

Не подскажешь, в чём может быть проблема?

[Question] Send token straight to omniauth_callback

Здравствуйте! Спасибо вам за этот гем.

Прошу меня простить за небольшой сумбур в тексте, не могу разобраться.

У меня есть android-приложение, на котором я получаю access_token через Android SDK. Есть ли способы отправить post запрос с access_token напрямую в omniauth_vk_callback_path? Так как это Standalone приложение, у меня нет возможности получать токен с сервера (redirect_uri стоит дефолтный от вк, т.е https://oauth.vk.com/blank.html ), но при этом нужна авторизация на клиенте и на сервере.

Заранее спасибо за ответ! ❤️

P.S Есть еще способ получить Authorization code, отправить его на сервер и уже с сервера сделать post запрос и получить access_token. Есть ли такая возможность сделать это используя данный гем?

wall post example

Would you please give an example how to make wall posts using omniauth-vkontakte?

Return empty extra and info hash

My Env :

oauth2 (0.8.0)
omniauth (1.1.1)
omniauth-facebook (1.4.1)
omniauth-oauth2 (1.1.1)
omniauth-vkontakte (1.1.0)
rails (2.3.8)

Omniauth-vkontakte return empty extra and info hash:

extra=#> info=#> provider="vkontakte" uid=88888888>

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.