class OmniAuth::Strategies::ORCID
Constants
- API_VERSION
Public Class Methods
new(app, *args, &block)
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/orcid.rb, line 28 def initialize(app, *args, &block) super @options.client_options.site = site @options.client_options.api_base_url = api_base_url @options.client_options.authorize_url = authorize_url @options.client_options.token_url = token_url end
Public Instance Methods
api_base_url()
click to toggle source
# File lib/omniauth/strategies/orcid.rb, line 77 def api_base_url if options[:sandbox] "https://pub.sandbox.orcid.org/v#{API_VERSION}" else "https://pub.orcid.org/v#{API_VERSION}" end end
callback_url()
click to toggle source
# File lib/omniauth/strategies/orcid.rb, line 153 def callback_url full_host + script_name + callback_path end
namespace()
click to toggle source
URLs for ORCID
OAuth: members.orcid.org/api/tokens-through-3-legged-oauth-authorization
# File lib/omniauth/strategies/orcid.rb, line 56 def namespace if options[:member] && options[:sandbox] 'sandbox' elsif options[:member] 'production' elsif options[:sandbox] 'public_sandbox' else 'public' end end
raw_info()
click to toggle source
retrieve all verified email addresses and include visibility (LIMITED vs. PUBLIC) and whether this is the primary email address all other information will in almost all cases be PUBLIC
# File lib/omniauth/strategies/orcid.rb, line 133 def raw_info @raw_info ||= { first_name: request_info.dig('name', 'given-names', 'value'), last_name: request_info.dig('name', 'family-name', 'value'), other_names: request_info.dig('other-names', 'other-name').map { |o| o.fetch('content') }, description: request_info.dig('biography', 'content'), location: request_info.dig('addresses', 'address').map { |a| a.dig('country', 'value') }.first, email: request_info.dig('emails', 'email') .select { |e| e.fetch('verified') }.find { |e| e.fetch('primary') }.to_h.fetch('email', nil), urls: request_info.dig('researcher-urls', 'researcher-url').map do |r| { r.fetch("url-name", nil) => r.dig('url', 'value') } end, external_identifiers: request_info.dig('external-identifiers', 'external-identifier').map do |e| { 'type' => e.fetch('external-id-type', nil), 'value' => e.fetch('external-id-value', nil), 'url' => e.dig('external-id-url', 'value') } end } end
request_info()
click to toggle source
# File lib/omniauth/strategies/orcid.rb, line 126 def request_info @request_info ||= client.request(:get, "#{api_base_url}/#{uid}/person", headers: { accept: 'application/json' }).parsed || {} end
root_url()
click to toggle source
# File lib/omniauth/strategies/orcid.rb, line 85 def root_url if options[:sandbox] 'https://sandbox.orcid.org' else 'https://orcid.org' end end
scope()
click to toggle source
# File lib/omniauth/strategies/orcid.rb, line 101 def scope if options[:member] '/read-limited /activities/update /person/update' else '/authenticate' end end
site()
click to toggle source
# File lib/omniauth/strategies/orcid.rb, line 68 def site case namespace when 'sandbox' then 'https://api.sandbox.orcid.org' when 'production' then 'https://api.orcid.org' when 'public_sandbox' then 'https://pub.sandbox.orcid.org' when 'public' then 'https://pub.orcid.org' end end
token_url()
click to toggle source
# File lib/omniauth/strategies/orcid.rb, line 97 def token_url root_url + '/oauth/token' end