MONGOC_OIDC_CALLBACK_T(3)
Okay bestie, this is the libmongoc page for MONGOC_OIDC_CALLBACK_T(3) β aka the mongoc_oidc_callback_t page. Buckle up, itβs OIDC callback time. π
β¨
β¨ SYNOPSIS β¨
typedef struct _mongoc_oidc_callback_t mongoc_oidc_callback_t;
Okay so mongoc_oidc_callback_t represents a user-defined callback function, mongoc_oidc_callback_fn_t, that returns an OIDC access token. Literally thatβs the whole vibe. π«Ά
This callback is your go-to when you need to integrate with OIDC providers that are not supported by the built-in provider integrations (the manual points at Authentication Mechanism Properties). No cap, itβs the custom-hookup route.
π¦ LIFECYCLE π¦
Hereβs the important part, bestie: the function and optional user data stored by mongoc_oidc_callback_t must outlive any associated client or client pool object which may invoke the stored callback function.
β οΈ Translation: do not let that callback or its user data vibe-check out early. It has to stick around longer than any client or client pool that might call it. π
π THREAD SAFETY π
Okay, thread-safety tea time. The callback function stored by a mongoc_oidc_callback_t object will be invoked by at most one thread at a time for an associated mongoc_client_t or mongoc_client_pool_t object:
static mongoc_oidc_credential_t *
single_thread_only (mongoc_oidc_callback_params_t *params)
{
// This function does not need to support invocation by more than thread at a time.
// ...
}
void
with_single_client (void)
{
mongoc_client_t *client = /* ... */;
{
mongoc_oidc_callback_t *callback = mongoc_oidc_callback_new (&single_thread_only);
BSON_ASSERT (mongoc_client_set_oidc_callback (client, callback));
mongoc_oidc_callback_destroy (callback);
}
// ... client operations ...
mongoc_client_destroy (client);
}
void
with_single_pool (void)
{
mongoc_client_pool_t *pool = /* ... */;
{
mongoc_oidc_callback_t *callback = mongoc_oidc_callback_new (&single_thread_only);
BSON_ASSERT (mongoc_client_pool_set_oidc_callback (pool, callback));
mongoc_oidc_callback_destroy (callback);
}
// ... client pool operations ...
mongoc_client_pool_destroy (pool);
}
But listen: if the callback is associated with more than one mongoc_client_t object (in multiple threads), or with more than one mongoc_client_pool_t object (even in a single thread), the callback function MUST support invocation by more than one thread at a time:
static mongoc_oidc_credential_t *
many_threads_possible (mongoc_oidc_callback_params_t *params)
{
// This function MUST support invocation by more than one thread at a time.
// ...
}
void
with_many_clients (void)
{
mongoc_client_t *client_a = /* ... */;
mongoc_client_t *client_b = /* ... */;
{
mongoc_oidc_callback_t *callback = mongoc_oidc_callback_new (&many_threads_possible);
BSON_ASSERT (mongoc_client_set_oidc_callback (client_a, callback));
BSON_ASSERT (mongoc_client_set_oidc_callback (client_b, callback));
mongoc_oidc_callback_destroy (callback);
}
pthread_t thread_a;
pthread_t thread_b;
if (pthread_create (&thread_a, NULL, /* thread_a_fn */, client_a) != 0) { /* ... */ }
if (pthread_create (&thread_b, NULL, /* thread_b_fn */, client_b) != 0) { /* ... */ }
// ... client operations using multiple threads ...
if (pthread_join (&thread_a, NULL) != 0) { /* ... */ }
if (pthread_join (&thread_b, NULL) != 0) { /* ... */ }
mongoc_client_destroy (client_a);
mongoc_client_destroy (client_b);
}
void
with_many_pools (void)
{
mongoc_client_pool_t *pool_a = /* ... */;
mongoc_client_pool_t *pool_b = /* ... */;
{
mongoc_oidc_callback_t *callback = mongoc_oidc_callback_new (&many_threads_possible);
BSON_ASSERT (mongoc_client_pool_set_oidc_callback (pool_a, callback));
BSON_ASSERT (mongoc_client_pool_set_oidc_callback (pool_b, callback));
mongoc_oidc_callback_destroy (callback);
}
// ... client operations using multiple client pools ...
mongoc_client_pool_destroy (pool_a);
mongoc_client_pool_destroy (pool_b);
}
π SEE ALSO π
mongoc_client_tmongoc_client_pool_tmongoc_oidc_callback_fn_tmongoc_oidc_callback_params_tmongoc_oidc_credential_t
πΈ AUTHOR πΈ
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
π Thatβs the whole page, bestie. This is from libmongoc version2.5.6, datedOct 09, 2026β now go be the main character of your OIDC callback setup. π β¨
π¦ 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