docs: document dependencies for auth provider (#10865)

* docs: document dependencies for auth provider

* fixes

* document overriding callback url
This commit is contained in:
Shahed Nasser
2025-01-07 16:42:45 +02:00
committed by GitHub
parent edcff0ed16
commit 60fd1cbc6c
9 changed files with 125 additions and 65 deletions
@@ -36,30 +36,36 @@ Learn about the authentication flow for third-party providers in [this guide](..
Add the module to the array of providers passed to the Auth Module:
```ts title="medusa-config.ts"
import { Modules } from "@medusajs/framework/utils"
import { Modules, ContainerRegistrationKeys } from "@medusajs/framework/utils"
// ...
const modules = {
module.exports = defineConfig({
// ...
[Modules.AUTH]: {
resolve: "@medusajs/medusa/auth",
options: {
providers: [
// other providers...
{
resolve: "@medusajs/medusa/auth-google",
id: "google",
options: {
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackUrl: process.env.GOOGLE_CALLBACK_URL,
},
modules: [
{
// ...
[Modules.AUTH]: {
resolve: "@medusajs/medusa/auth",
dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
options: {
providers: [
// other providers...
{
resolve: "@medusajs/medusa/auth-google",
id: "google",
options: {
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackUrl: process.env.GOOGLE_CALLBACK_URL,
},
},
],
},
],
},
},
}
},
}
],
})
```
### Environment Variables
@@ -141,6 +147,16 @@ GOOGLE_CALLBACK_URL=<YOUR_GOOGLE_CALLBACK_URL>
---
---
## Override Callback URL During Authentication
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](../../authentication-route/page.mdx#login-route) can accept a `callback_url` body parameter to override the provider's `callbackUrl` option. Learn more in [this documentation](../../authentication-route/page.mdx#login-route).
---
## Examples
- [How to implement Google social login in the storefront](../../../../storefront-development/customers/third-party-login/page.mdx).