46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/omniauth/strategies/jira_oauth2.rb', line 46
def raw_info
return @raw_info if @raw_info
accessible_resources_url = 'https://api.atlassian.com/oauth/token/accessible-resources'
sites = JSON.parse(access_token.get(accessible_resources_url).body)
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
|