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:
- Obtain API key for your app at Yandex OAuth app registration page
- Enter callback url for auth
- Select service and its data for auth
-
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.
- Kir Shatrov - Initial work
- Dmitry Koropenko - Maintainer
See also the list of contributors who participated in this project.
This project is licensed under the MIT License.