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
發布數23
最新版本名稱v1.7.3 (發布於 2022-06-19 08:45:48)
第一版名稱v1.0.0.pr1 (發布於 2011-10-12 19:28:26)
創建於2011-09-28 16:48:31
推送於2024-01-12 20:21:20
最后一次提交2023-10-12 14:47:14
星數491
關注者數11
派生數301
提交數229
已啟用問題?
問題數86
打開的問題數39
拉請求數48
打開的拉請求數11
關閉的拉請求數28
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部