Sha256: a02d538f74e891bf5711336881275b116aadbaa5d2c76573b1ad02c6603dbc5d

Contents?: true

Size: 968 Bytes

Versions: 1

Compression:

Stored size: 968 Bytes

Contents

# frozen_string_literal: true

require "omniauth-oauth2"

module OmniAuth
  module Strategies
    class Smaregi < OmniAuth::Strategies::OAuth2
      option :name, "smaregi"

      option :client_options, {
        site: "https://id.smaregi.dev",
        authorize_url: "https://id.smaregi.dev/authorize",
        token_url: "https://id.smaregi.dev/authorize/token"
      }

      option :authorize_options, [:scope]

      uid { raw_info["contract"]["id"] }

      info { raw_info }

      def raw_info
        @raw_info ||= access_token.get("/userinfo").parsed
      end

      def callback_url
        full_host + script_name + callback_path
      end

      def build_access_token
        client.auth_code.get_token(
          request.params["code"],
          verifier,
          {
            redirect_uri: callback_url
          }.merge(token_params.to_hash(symbolize_keys: true)), deep_symbolize(options.auth_token_params)
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-smaregi-0.1.0 lib/omniauth/strategies/smaregi.rb