Omniauth 1.0 strategy for Yandex.ru
MIT License
This gem contains the unofficial Yandex OAuth2 strategy for OmniAuth.
This gem require OmniAuth
But you no need add gem 'omniauth'
.
This gem already added.
gem "omniauth-yandex"
Register new app for sync on yandex:
Add to omniauth.rb yandex provider:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :yandex, ENV['YANDEX_ID'], ENV['YANDEX_PASSWORD']
end
Add route
get '/auth/:provider/callback', to: 'sessions#create'
Create SessionController
class SessionsController < ApplicationController
def create
@user = User.find_or_create_from_auth_hash(auth_hash)
redirect_to '/'
end
protected
def auth_hash
request.env['omniauth.auth']
end
end
Run rails server and open page
localhost:3000/auth/yandex
Sign In yandex by own username and password
Take app permissions:
Please read Code of Conduct and Contributing Guidelines for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
The changelog is here.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License.