class OmniAuth::Strategies::JiraOauth2
Omniauth strategy for Atlassian
Public Instance Methods
raw_info()
click to toggle source
# File lib/omniauth/strategies/jira_oauth2.rb, line 46 def raw_info return @raw_info if @raw_info # NOTE: api.atlassian.com, not auth.atlassian.com! accessible_resources_url = 'https://api.atlassian.com/oauth/token/accessible-resources' sites = JSON.parse(access_token.get(accessible_resources_url).body) # Jira's OAuth gives us many potential sites. To request information # about the user for the OmniAuth hash, pick the first one that has the # necessary 'read:jira-user' scope. jira_user_scope = 'read:jira-user' site = sites.find do |candidate_site| candidate_site['scopes'].include?(jira_user_scope) end unless site raise "No site found with scope #{jira_user_scope}, please ensure the scope ${jira_user_scope} is added to your OmniAuth config" end cloud_id = site['id'] base_url = "https://api.atlassian.com/ex/jira/#{cloud_id}" myself_url = "#{base_url}/rest/api/3/myself" myself = JSON.parse(access_token.get(myself_url).body) @raw_info ||= { 'site' => site, 'sites' => sites, 'myself' => myself } end