MONGOC_OIDC_CALLBACK_PARAMS_T(3)
Hey bestie π welcome to MONGOC_OIDC_CALLBACK_PARAMS_T(3) from libmongoc β the manual page for the in/out parameter struct that OIDC callbacks pass around like itβs the group chat. β¨
β¨ SYNOPSIS β¨
typedef struct _mongoc_oidc_callback_params_t mongoc_oidc_callback_params_t;
Okay so this typedef is literally the in/out parameters of a mongoc_oidc_callback_t.
These parameters get passed to the mongoc_oidc_callback_fn_t stored in an mongoc_oidc_callback_t object when it is invoked by an mongoc_client_t or mongoc_client_pool_t object. No cap, thatβs the whole flow. π«Ά
π PARAMETERS π
The list of currently supported parameters are:
versionβ Versions:1β The current OIDC callback API version number.user_dataβ Versions:1β A pointer to data provided by the user.timeoutβ Versions:1β The timestamp after which the callback function must report a timeout.usernameβ Versions:1β The username specified by the URI of the associated client object.cancel_with_timeoutβ Versions:1β An out parameter indicating cancellation of the callback function due to a timeout instead of an error.
The Versions column tells you the OIDC callback API versions for which the parameter is applicable β and every parameter above is sitting pretty at version 1. π
πΈ Version πΈ
The version parameter is used to communicate backward compatible changes to the OIDC callback API (i.e. the addition of a new parameter). Lowkey important.
This parameter may be used to detect when existing usage of mongoc_oidc_callback_t or a relevant callback function may need to be reviewed.
For example, users may add the following check to their callback function:
mongoc_oidc_credential_t *
example_callback_fn (mongoc_oidc_callback_params_t *params)
{
// A runtime message that new features are available in the OIDC Callback API.
if (mongoc_oidc_callback_params_get_version (params) > 1) {
printf ("OIDC Callback API has been updated to a new version!");
}
// ...
}
π¦ User Data π¦
The user_data parameter may be used to pass additional arguments to the callback function or to return additional values out of the callback function. Itβs giving βsneaky little side channelβ energy. π
This parameter must be set in advance via mongoc_oidc_callback_set_user_data() before the mongoc_oidc_callback_t object is associated with a mongoc_client_t or mongoc_client_pool_t object.
WARNING: The lifetime of the object pointed to byuser_datais managed by the user, not bymongoc_oidc_callback_t! Do not forget this one, bestie. π
typedef struct {
int counter;
const char *error_message;
} user_data_t;
mongoc_oidc_credential_t *
example_callback_fn (mongoc_oidc_callback_params_t *params)
{
user_data_t *user_data = (user_data_t *) mongoc_oidc_callback_params_get_user_data (params);
user_data->counter += 1;
// ...
if (/* ... */) {
user_data->error_message = "OIDC callback failed due to ...";
return NULL;
}
// ...
}
void
example (void)
{
mongoc_client_t *client = /* ... */;
bson_error_t error;
{
user_data_t *user_data = malloc (sizeof (*user_data));
*user_data = (user_data_t){.counter = 0, .error_message = NULL};
mongoc_oidc_callback_t *callback = mongoc_oidc_callback_new_with_user_data (&example_callback_fn, (void *) user_data);
BSON_ASSERT (mongoc_client_set_oidc_callback (client, callback));
mongoc_oidc_callback_destroy (callback);
}
// ... client operations ...
{
const mongoc_oidc_callback_t *callback = mongoc_client_get_oidc_callback (client);
user_data_t *user_data = (user_data_t *) mongoc_oidc_callback_get_user_data (callback);
if (error.code != 0) {
printf ("client error message: %s\n", error.message);
}
if (user_data->error_message) {
printf ("custom error message: %s\n", user_data->error_message);
}
printf ("The callback function was invoked %d times!", user_data->counter);
free (user_data);
}
mongoc_client_destroy (client);
}
β° Timeout β°
The timeout parameter is used to determine when the callback function should report cancellation due to a timeout.
When System Clock is greater than timeout, the callback function must invoke mongoc_oidc_callback_params_cancel_with_timeout() and return NULL. Clock says timeβs up, so behave accordingly. β³
π Username π
The username parameter is the value of the username component of the URI of the associated mongoc_client_t or mongoc_client_pool_t object from which the callback function is invoked. Main character username energy. π
π Cancel With Timeout π
The cancel_with_timeout out parameter indicates cancellation of the callback function due to a timeout instead of an error.
IMPORTANT: The callback function MUST returnNULL, otherwise the invocation will be interpreted as a success even whencancel_with_timeoutis set. Do not let this one slide, fr fr. π¨
mongoc_oidc_credential_t *
example_callback_fn (mongoc_oidc_callback_params_t *params) {
const int64_t *timeout = mongoc_oidc_callback_params_get_timeout (params);
// NULL means "infinite" timeout.
if (timeout && bson_get_monotonic_time () > *timeout) {
return mongoc_oidc_callback_params_cancel_with_timeout (params);
}
// ...
}
π Error Handling π
A NULL return value (without setting cancel_with_timeout) indicates failure to provide an access token due to an error.
IMPORTANT: The callback function MUST return NULL, otherwise the invocation will be interpreted as a success. This is not a drill. π
mongoc_oidc_credential_t *
example_callback_fn (mongoc_oidc_callback_params_t *params) {
// ...
if (/* ... */) {
// The OIDC callback function could not provide an access token due to an error.
return NULL;
}
// ...
}
π SEE ALSO π
mongoc_oidc_callback_tmongoc_oidc_callback_fn_t
βοΈ AUTHOR βοΈ
MongoDB, Inc
Β©οΈ COPYRIGHT Β©οΈ
2009-present, MongoDB, Inc.
Thatβs the whole vibe, bestie π
β¨ This page is from libmongoc version 2.5.6, dated Oct 09, 2026. Now go slay those OIDC callbacks! ππ¦πΈ
π¦ where this page comes from
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms