5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/omniauth/strategies/qiita/client.rb', line 5
def get_token_with_json(params, access_token_opts = {}, access_token_class = AccessToken)
opts = {:raise_errors => options[:raise_errors], :parse => params.delete(:parse)}
if options[:token_method] == :post
= params.delete(:headers)
opts[:body] = params.to_json
opts[:headers] = {'Content-Type' => 'application/json'}
opts[:headers].merge!() if
else
opts[:params] = params
end
response = request(options[:token_method], token_url, opts)
error = Error.new(response)
fail(error) if options[:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['token'])
access_token_class.from_hash(self, response.parsed.merge(access_token_opts))
end
|