omniauth-oauth2

An abstract OAuth2 strategy for OmniAuth.

Github星跟踪图

OmniAuth OAuth2

Gem Version
Build Status
Dependency Status
Code Climate
Coverage Status
Security

This gem contains a generic OAuth2 strategy for OmniAuth. It is meant to serve
as a building block strategy for other strategies and not to be used
independently (since it has no inherent way to gather uid and user info).

Creating an OAuth2 Strategy

To create an OmniAuth OAuth2 strategy using this gem, you can simply subclass
it and add a few extra methods like so:

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class SomeSite < OmniAuth::Strategies::OAuth2
      # Give your strategy a name.
      option :name, "some_site"

      # This is where you pass the options you would pass when
      # initializing your consumer from the OAuth gem.
      option :client_options, {:site => "https://api.somesite.com"}

      # These are called after authentication has succeeded. If
      # possible, you should try to set the UID without making
      # additional calls (if the user id is returned with the token
      # or as a URI parameter). This may not be possible with all
      # providers.
      uid{ raw_info['id'] }

      info do
        {
          :name => raw_info['name'],
          :email => raw_info['email']
        }
      end

      extra do
        {
          'raw_info' => raw_info
        }
      end

      def raw_info
        @raw_info, = access_token.get('/me').parsed
      end
    end
  end
end

That's pretty much it!

主要指标

概览
名称与所有者omniauth/omniauth-oauth2
主编程语言Ruby
编程语言Ruby (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2011-09-28 16:48:31
推送于2024-09-03 22:26:17
最后一次提交2023-10-12 14:47:14
发布数23
最新版本名称v1.7.3 (发布于 2022-06-19 08:45:48)
第一版名称v1.0.0.pr1 (发布于 2011-10-12 19:28:26)
用户参与
星数505
关注者数10
派生数305
提交数229
已启用问题?
问题数89
打开的问题数40
拉请求数48
打开的拉请求数15
关闭的拉请求数29
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?