Skip to content

Latest commit

 

History

History
101 lines (61 loc) · 2.79 KB

README.md

File metadata and controls

101 lines (61 loc) · 2.79 KB

Yandex OAuth strategy for OmniAuth

travis Maintainability Reviewed by Hound

This gem contains the unofficial Yandex OAuth2 strategy for OmniAuth.

Sponsored by Evrone

Getting Started

Prerequisites

This gem require OmniAuth

But you no need add gem 'omniauth'.

This gem already added.

Installation

gem "omniauth-yandex"

Register new app for sync on yandex:

  1. Obtain API key for your app at Yandex OAuth app registration page
  2. Enter callback url for auth

  1. Select service and its data for auth

Usage

  1. Add to omniauth.rb yandex provider:

     Rails.application.config.middleware.use OmniAuth::Builder do
         provider :yandex, ENV['YANDEX_ID'], ENV['YANDEX_PASSWORD']
     end
    
  2. Add route

     get '/auth/:provider/callback', to: 'sessions#create'
    
  3. Create SessionController

note: This controller only as example how to create user by callback
    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
  1. Run rails server and open page

    localhost:3000/auth/yandex

  2. Sign In yandex by own username and password

  3. Take app permissions:

Contributing

Please read Code of Conduct and Contributing Guidelines for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Changelog

The changelog is here.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License.

Acknowledgments