- POST /token#
This is the token endpoint of the OAuth 2.0 specification. This endpoint is used by the client to provide its authorization code, demonstrating that it has the right to learn a particular user’s validated address. In return, the challenger service returns the access token. Renewal is not supported.
Request:
The request must include an
application/x-www-form-urlencodedbody (multipart/form-datais accepted as well) specifying theclient_id,redirect_uri,client_secret,codeandgrant_type. Thegrant_typemust be set toauthorization_code. Theredirect_urimust match the URI from/authorize. Thecodemust be the authorization code that/solvereturned to the user. Theclient_idandclient_secretmust match the usual client credentials. Since protocol v3,code_verifiercan also be included.The request body is limited to 2048 bytes, as is each individual field. Note that the client credentials must be passed in the body (
client_secret_post); HTTP Basic authentication (client_secret_basic) is not supported.Response:
Error responses follow RFC 6749, section 5.2 with an “error” field in JSON, as well as also returning GNU Taler style error messages. The
errorvalues used areinvalid_request,unsupported_grant_type,invalid_client,invalid_grantandserver_error. Since protocol v8 every error response of this endpoint carries theerrorfield, including415,413and500.- 200 OK:
The body will be a ChallengerAuthResponse.
- 400 Bad Request:
A required POST field (
grant_type,client_id,client_secret,codeorredirect_uri) is missing or malformed,grant_typeis notauthorization_code, or the authorization code was not accepted. Error codes used are:TALER_EC_GENERIC_PARAMETER_MISSING(errorisinvalid_request, orinvalid_grantfor a missingcode_verifier) — a required field is absent;detailnames it.TALER_EC_GENERIC_PARAMETER_MALFORMED(errorisinvalid_request, orunsupported_grant_typewhen thegrant_typeis notauthorization_code) — theContent-Lengthheader is not a number,client_idis not a number, or thecode_verifierviolates the length (43–128) or character-set rules of RFC 7636.TALER_EC_CHALLENGER_CLIENT_FORBIDDEN_BAD_CODE(errorisinvalid_grant) — thecodeis not well-formed, does not correspond to a solved validation of this client, does not match its recomputed authentication tag, or thecode_verifierdoes not match the storedcode_challenge.TALER_EC_CHALLENGER_GRANT_UNKNOWN(errorisinvalid_grant) — the authorization code was already redeemed, or the validation expired between the two database transactions.
Note
Several of these conditions are answered with a byte-identical response on purpose, so that a caller cannot use
/tokenas an oracle to distinguish “this nonce does not exist” from “this validation has no address” from “your authentication tag is wrong”.- 401 Unauthorized:
Authentication of the client failed (per RFC 6749, section 5.2): either the
client_id/client_secretpair is invalid, or theredirect_uridoes not match the one registered with the client. Error codes used are:TALER_EC_CHALLENGER_CLIENT_AUTHENTICATION_FAILED— theclient_id/client_secretpair does not match a registered client. Since protocol v8; previouslyTALER_EC_CHALLENGER_GENERIC_CLIENT_UNKNOWN, which is now used only by/setup/$CLIENT_IDwith a404so that each error code maps to exactly one HTTP status.TALER_EC_CHALLENGER_GENERIC_CLIENT_FORBIDDEN_BAD_REDIRECT_URI
Both are returned with
errorset toinvalid_clientand aWWW-Authenticate: Bearer error="invalid_client"header. Note that failures concerning thecodeitself — including PKCEcode_verifiermismatches, which exist since protocol v3 — are reported with400, not401.- 405 Method Not Allowed:
The request used a method other than
POSTorOPTIONS. Returned by the request router with anAllowheader and an empty body; in particular there is no Taler error code.- 409 Conflict:
A
codewas presented for a validation process for which the user has not (yet) submitted any address, so the token cannot be issued. Returned withTALER_EC_CHALLENGER_MISSING_ADDRESS. Removed in v8 (to better match RFC 6749, section 5.2); the condition is now reported as400withTALER_EC_CHALLENGER_CLIENT_FORBIDDEN_BAD_CODE.- 413 Request entity too large:
The request body exceeds the 2048 byte limit. Returned with
TALER_EC_GENERIC_UPLOAD_EXCEEDS_LIMITanderrorset toinvalid_request.- 415 Unsupported Media Type:
The
Content-Typeis missing or is not one the service can parse. Returned withTALER_EC_GENERIC_PARAMETER_MALFORMED,detailset to"Content-Type"anderrorset toinvalid_request. Since protocol v8; previously reported as400.- 500 Internal Server Error:
The challenger service encountered an internal error, for example a database failure or a failure of the SHA-256 or Base64 helpers used for PKCE verification. Error codes used are:
TALER_EC_GENERIC_DB_FETCH_FAILED—detailis"get_client"or"get_validation_pkce".TALER_EC_GENERIC_DB_STORE_FAILED—detailis"do_insert_token".TALER_EC_GENERIC_DB_SOFT_FAILURE— a serialization failure that survived all retries.TALER_EC_GENERIC_DB_INVARIANT_FAILURE(errorisserver_error) — the stored validation has acode_challengebut no challenge method.TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE(errorisserver_error) — the SHA-256 or Base64 helper used for PKCE verification failed.
All of these carry
errorset toserver_error. Note that the storedcode_challenge_methodbeing unknown is reported withTALER_EC_GENERIC_DB_INVARIANT_FAILUREsince protocol v8; it previously usedTALER_EC_GENERIC_PARAMETER_MALFORMED, which wrongly suggested the client’s request was at fault.
Details::
interface ChallengerAuthResponse { // Token used to authenticate access in /info. access_token: string; // Type of the access token. token_type: "Bearer"; // Amount of time that an access token is valid (in seconds). expires_in: Integer; }