Method: CF::UAA::TokenIssuer#authcode_grant

Defined in:
lib/uaa/token_issuer.rb

#authcode_grant(authcode_uri, callback_query) ⇒ TokenInfo

Uses the instance client credentials in addition to callback_query to get a token via the authorization code grant.

Parameters:

  • authcode_uri (String)

    must be from a previous call to #authcode_uri and contains state used to validate the contents of the reply from the server.

  • callback_query (String)

    must be the query portion of the URL received by the client after the user’s browser is redirected back from the server. It contains the authorization code.

Returns:

See Also:



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/uaa/token_issuer.rb', line 214

def authcode_grant(authcode_uri, callback_query)
  ac_params = Util.decode_form(URI.parse(authcode_uri).query)
  unless ac_params['state'] && ac_params['redirect_uri']
    raise ArgumentError, "authcode redirect must happen before authcode grant"
  end
  begin
    params = Util.decode_form(callback_query)
    authcode = params['code']
    raise BadResponse unless params['state'] == ac_params['state'] && authcode
  rescue URI::InvalidURIError, ArgumentError, BadResponse
    raise BadResponse, "received invalid response from target #{@target}"
  end
  request_token(:grant_type => 'authorization_code', :code => authcode,
      :redirect_uri => ac_params['redirect_uri'])
end