diff --git a/source/code-snippets/authentication/oidc-callbacks.ts b/source/code-snippets/authentication/oidc-callbacks.ts new file mode 100644 index 000000000..9bc6d64cd --- /dev/null +++ b/source/code-snippets/authentication/oidc-callbacks.ts @@ -0,0 +1,18 @@ +import { MongoClient } from 'mongodb'; +import { createMongoDBOIDCPlugin } from '@mongodb-js/oidc-plugin'; + +// All config options are optional. +// Please see https://github.com/mongodb-js/oidc-plugin/#example-usage for more information. +const config = { + openBrowser: { + command: 'open -a "Firefox"', + }, + allowedFlows: ['auth-code'] +}; + +const client = await MongoClient.connect( + 'mongodb+srv://.../?authMechanism=MONGODB-OIDC', + { + ...createMongoDBOIDCPlugin(config).mongoClientOptions, + } +);