Sha256: 9914b691a65e4c9e3437d23ce5759aa4a878144fdfbe9cf82775a0c603e20fa4

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class Identitas < OmniAuth::Strategies::OAuth2
      # change the class name and the :name option to match your application name
      option :name, :identitas

      option :client_options, {
        site: "https://api.identitas.com",
        authorize_url: "/oauth/authorize"
      }

      uid { raw_info["id"] }

      info do
        {
          email: raw_info["email"],
          first_name: raw_info["first_name"],
          last_name: raw_info["last_name"],
          name: [raw_info["first_name"], raw_info["last_name"]].join(" ")
        }
      end

      extra do
        {
          m: request.params["m"]
        }
      end

      def raw_info
        @raw_info ||= access_token.get('/v1/me.json').parsed
      rescue ::Errno::ETIMEDOUT
        raise ::Timeout::Error
      end

      # # https://github.com/intridea/omniauth-oauth2/issues/81
      def callback_url
        full_host + script_name + callback_path + check_if_mobile
      end

      def check_if_mobile
        "?" + {m: options.authorize_params[:m]}.to_query
      end

      def setup_phase
        options.authorize_params[:m] = request.params["m"]
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-identitas-0.2.1 lib/omniauth/strategies/identitas.rb