Sha256: 9bd21104bde408a2008874d45d5c10148e7d423955f11cf5408095149e9c7e97

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 Bytes

Contents

require "omniauth-oauth2"
require "oauth2"

module OmniAuth
  module Strategies
    class Nctu < OmniAuth::Strategies::OAuth2
      OAuthUrl = "https://id.nctu.edu.tw"

      option :name, "nctu"

      option :client_options, {
        site:           OAuthUrl,
        authorize_url:  "#{OAuthUrl}/o/authorize/",
        token_url:      "#{OAuthUrl}/o/token/"
      }

      uid do
        raw_info["username"]
      end

      info do
        {
          :email => raw_info["email"],
          :name => raw_info["username"],
          :image => "http://museum.lib.nctu.edu.tw/share/mark.gif"
        }
      end

      extra do
        {
          "raw_info" => raw_info
        }
      end

      def raw_info
        access_token.options[:mode] = :header
        @raw_info ||= access_token.get("/api/profile/").parsed
      end

      def callback_url
        full_host + script_name + callback_path
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-nctu-1.0.2 lib/omniauth/strategies/nctu.rb