32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/devise/oauth_token_authenticatable/models/oauth_token_authenticatable.rb', line 32
def validate_oauth_token(token_str)
@@client ||= ::OAuth2::Client.new(oauth_client_id, oauth_client_secret, oauth_client_options)
params = { client_id: oauth_client_id,
access_token: token_str
}
access_token_opts = {}
opts = {}
if @@client.options[:token_method] == :post
= params.delete(:headers)
opts[:body] = params
opts[:headers] = {'Content-Type' => 'application/x-www-form-urlencoded'}
opts[:headers].merge!() if
else
opts[:params] = params
end
response = @@client.request(@@client.options[:token_method], oauth_token_validation_url, opts)
raise ::OAuth2::Error.new(response) if @@client.options[:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['access_token'])
::OAuth2::AccessToken.from_hash(@@client, response.parsed.merge(access_token_opts))
end
|