Sha256: d342ecc922447a6e1918b4b2bb84ea38b336610a0dc9bf3e63d67d0942ba9bdf
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require 'omniauth-oauth2' module OmniAuth module Strategies class Namecheap < OmniAuth::Strategies::OAuth2 # This is where you pass the options you would pass when # initializing your consumer from the OAuth gem. option :client_options, site: 'https://www.namecheap.com', authorize_url: '/apps/sso/api/authorize', token_url: '/apps/sso/api/token', me_url: '/apps/sso/api/resource/user' # 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['sub'] } info { deep_symbolize(raw_info) } def request_phase session[:namecheap_omnniauth_callback_url] = callback_url super end def raw_info @raw_info ||= JSON.parse(access_token.get(client.options[:me_url]).body) end def build_access_token params = { redirect_uri: saved_callback_url }.merge(token_params.to_hash(symbolize_keys: true)) auth_token_params = deep_symbolize(options.auth_token_params) client.auth_code.get_token(request.params['code'], params, auth_token_params) end private def saved_callback_url session[:namecheap_omnniauth_callback_url] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
omniauth-namecheap-0.2.1 | lib/omniauth/strategies/namecheap.rb |
omniauth-namecheap-0.2.0 | lib/omniauth/strategies/namecheap.rb |