Skip to content

Declared in <galanthus/c_api/gln_capi.h>.

GLN_API gln_status_t GLN_CALL gln_revolut_oauth_exchange_code(
    gln_backend_t*                                   in_backend,
    const gln_revolut_oauth_exchange_code_request_t* in_request,
    gln_error_t*                                     out_error);
  • Family: Revolut OAuth setup
  • Return type: gln_status_t

Purpose

Exchanges a Revolut OAuth authorization code for persisted token state.

The public C API returns only status information; token material is stored through the backend's configured token storage and is never returned to the caller.

Return

Returns GLN_OK on success and a non-OK gln_status_t value on failure.

TypeNullabilityOwnership
gln_status_tvaluevalue

Parameters

NameDirectionTypeNullabilityOwnership
in_backendinputgln_backend_t*nonnullborrowed
in_requestinputconst gln_revolut_oauth_exchange_code_request_t*nonnullborrowed
out_erroroutputgln_error_t*nullablecaller_allocated_output

Request

Initialize gln_revolut_oauth_exchange_code_request_t by calling gln_default_revolut_oauth_exchange_code_request before filling fields.

authorization_code, expected_state, and received_state are required borrowed C strings. The library copies only the values it needs for the exchange request.

expected_state must exactly match received_state. A mismatch fails the call with GLN_ERR_INVALID_ARG and the issue code oauth_state_mismatch; it is an error, not a warning or partial success.

Token Storage

On a successful exchange, the resulting token state is persisted to the Revolut token store bound to the backend and to the backend profile storage when a profile name was configured.

Persist failures return GLN_ERR_TOKEN_PERSIST_FAILED. Use token-persist error detail helpers to inspect the failing persistence operation.

The result shape intentionally contains no token strings, key material, or authorization header values.

Example

gln_revolut_oauth_exchange_code_request_t request = {0};
gln_default_revolut_oauth_exchange_code_request(&request);
request.authorization_code = authorization_code_from_redirect;
request.expected_state = remembered_oauth_state;
request.received_state = state_from_redirect;

gln_error_t error = {0};

gln_default_error(&error);
gln_status_t rc = gln_revolut_oauth_exchange_code(backend, &request, &error);
if (rc != GLN_OK) {
    handle_oauth_exchange_failure(&error);
}

gln_release_error(&error);

See Also