on GitHub" data-tooltip-id=":Rblcldb:">v2.6·
In this document, you’ll learn about the Google Auth Module Provider and how to install and use it in the Auth Module.
The Google Auth Module Provider authenticates users with their Google account.
Add the module to the array of providers passed to the Auth Module:
1import { Modules, ContainerRegistrationKeys } from "@medusajs/framework/utils"2 3// ...4 5module.exports = defineConfig({6 // ...7 modules: [8 {9 // ...10 [Modules.AUTH]: {11 resolve: "@medusajs/medusa/auth",12 dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],13 options: {14 providers: [15 // other providers...16 {17 resolve: "@medusajs/medusa/auth-google",18 id: "google",19 options: {20 clientId: process.env.GOOGLE_CLIENT_ID,21 clientSecret: process.env.GOOGLE_CLIENT_SECRET,22 callbackUrl: process.env.GOOGLE_CALLBACK_URL,23 },24 },25 ],26 },27 },28 },29 ],30})
Make sure to add the necessary environment variables for the above options in .env
:
Configuration | Description | Required |
---|---|---|
| A string indicating the Google API Client ID. | Yes |
| A string indicating the Google Client Secret. | Yes |
| A string indicating the URL to redirect to in your frontend after the user completes their authentication in Google. At this URL, the frontend will receive a | Yes |
In many cases, you may have different callback URL for actor types. For example, you may redirect admin users to a different URL than customers after authentication.
The Authenticate or Login API Route can accept a callback_url
body parameter to override the provider's callbackUrl
option. Learn more in this documentation.