lib/uaa/token_issuer.rb in cf-uaa-lib-1.3.2 vs lib/uaa/token_issuer.rb in cf-uaa-lib-1.3.3
- old
+ new
@@ -70,12 +70,11 @@
# returns a CF::UAA::TokenInfo object which includes the access token and metadata.
def request_token(params)
if scope = Util.arglist(params.delete(:scope))
params[:scope] = Util.strlist(scope)
end
- headers = {'content-type' => 'application/x-www-form-urlencoded',
- 'accept' => 'application/json',
+ headers = {'content-type' => FORM_UTF8, 'accept' => JSON_UTF8,
'authorization' => Http.basic_auth(@client_id, @client_secret) }
reply = json_parse_reply(@key_style, *request(@token_target, :post,
'/oauth/token', Util.encode_form(params), headers))
raise BadResponse unless reply[jkey :token_type] && reply[jkey :access_token]
TokenInfo.new(reply)
@@ -132,11 +131,11 @@
# this manufactured redirect_uri is a convention here, not part of OAuth2
redir_uri = "https://uaa.cloudfoundry.com/redirect/#{@client_id}"
uri = authorize_path_args("token", redir_uri, scope, state = random_state)
# the accept header is only here so the uaa will issue error replies in json to aid debugging
- headers = {'content-type' => 'application/x-www-form-urlencoded', 'accept' => 'application/json' }
+ headers = {'content-type' => FORM_UTF8, 'accept' => JSON_UTF8 }
body = Util.encode_form(credentials.merge(:source => 'credentials'))
status, body, headers = request(@target, :post, uri, body, headers)
raise BadResponse, "status #{status}" unless status == 302
req_uri, reply_uri = URI.parse(redir_uri), URI.parse(headers['location'])
fragment, reply_uri.fragment = reply_uri.fragment, nil
@@ -182,11 +181,10 @@
# in their credentials again.
# @param [String] credentials (see #implicit_grant_with_creds)
# @param [String] redirect_uri (see #authcode_uri)
# @return (see #authcode_uri)
def autologin_uri(redirect_uri, credentials, scope = nil)
- headers = {'content-type' => 'application/x-www-form-urlencoded',
- 'accept' => 'application/json',
+ headers = {'content-type' => FORM_UTF8, 'accept' => JSON_UTF8,
'authorization' => Http.basic_auth(@client_id, @client_secret) }
body = Util.encode_form(credentials)
reply = json_parse_reply(nil, *request(@target, :post, "/autologin", body, headers))
raise BadResponse, "no autologin code in reply" unless reply['code']
@target + authorize_path_args('code', redirect_uri, scope,