docs: fixes to JS SDK + auth provider guides (#13526)

* docs: fixes to JS SDK + auth provider guides

* more fixes

* fix lint error
This commit is contained in:
Shahed Nasser
2025-09-16 18:39:56 +03:00
committed by GitHub
parent 92102dcafb
commit 1c4f7bd53a
3 changed files with 46 additions and 42 deletions

View File

@@ -24900,7 +24900,7 @@ The Google Auth Module Provider allows you to authenticate users with their Goog
### Prerequisites
- [Create a project in Google Cloud.](https://cloud.google.com/resource-manager/docs/creating-managing-projects)
- [Create authorization credentials. When setting the Redirect Uri, set it to a URL in your frontend that later uses Medusa's callback route to validate the authentication.](https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred)
- [Create Oauth client ID credentials. When setting the Redirect Uri, set it to a URL in your frontend (for example, storefront) that later uses Medusa's callback route to validate the authentication.](https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred)
To use the Google Auth Module Provider, add the module to the array of providers passed to the Auth Module in your `medusa-config.ts`:
@@ -24912,25 +24912,27 @@ import { Modules, ContainerRegistrationKeys } from "@medusajs/framework/utils"
module.exports = defineConfig({
// ...
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,
},
resolve: "@medusajs/medusa/auth",
dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
options: {
providers: [
// other providers...
{
resolve: "@medusajs/medusa/auth-emailpass",
id: "emailpass",
},
{
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,
},
],
},
},
],
},
},
],
@@ -45033,7 +45035,7 @@ For admin customizations, create this file at `src/admin/lib/config.ts`.
### Admin (Medusa project)
```ts title="src/admin/lib/config.ts"
```ts title="src/admin/lib/sdk.ts"
import Medusa from "@medusajs/js-sdk"
export const sdk = new Medusa({
@@ -45047,7 +45049,7 @@ export const sdk = new Medusa({
### Admin (Medusa Plugin)
```ts title="src/admin/lib/config.ts"
```ts title="src/admin/lib/sdk.ts"
import Medusa from "@medusajs/js-sdk"
export const sdk = new Medusa({
@@ -45061,7 +45063,7 @@ export const sdk = new Medusa({
### Storefront
```ts title="config.ts"
```ts title="sdk.ts"
import Medusa from "@medusajs/js-sdk"
let MEDUSA_BACKEND_URL = "http://localhost:9000"

View File

@@ -19,7 +19,7 @@ The Google Auth Module Provider allows you to authenticate users with their Goog
link: "https://cloud.google.com/resource-manager/docs/creating-managing-projects"
},
{
text: "Create authorization credentials. When setting the Redirect Uri, set it to a URL in your frontend that later uses Medusa's callback route to validate the authentication.",
text: "Create Oauth client ID credentials. When setting the Redirect Uri, set it to a URL in your frontend (for example, storefront) that later uses Medusa's callback route to validate the authentication.",
link: "https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred"
}
]}
@@ -35,25 +35,27 @@ import { Modules, ContainerRegistrationKeys } from "@medusajs/framework/utils"
module.exports = defineConfig({
// ...
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,
},
resolve: "@medusajs/medusa/auth",
dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
options: {
providers: [
// other providers...
{
resolve: "@medusajs/medusa/auth-emailpass",
id: "emailpass",
},
{
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,
},
],
},
},
],
},
},
],

View File

@@ -44,7 +44,7 @@ For admin customizations, create this file at `src/admin/lib/config.ts`.
<CodeTabs group="sdk-project">
<CodeTab label="Admin (Medusa project)" value="admin-medusa-project">
```ts title="src/admin/lib/config.ts"
```ts title="src/admin/lib/sdk.ts"
import Medusa from "@medusajs/js-sdk"
export const sdk = new Medusa({
@@ -59,7 +59,7 @@ export const sdk = new Medusa({
</CodeTab>
<CodeTab label="Admin (Medusa Plugin)" value="admin-medusa-plugin">
```ts title="src/admin/lib/config.ts"
```ts title="src/admin/lib/sdk.ts"
import Medusa from "@medusajs/js-sdk"
export const sdk = new Medusa({
@@ -74,7 +74,7 @@ export const sdk = new Medusa({
</CodeTab>
<CodeTab label="Storefront" value="storefront">
```ts title="config.ts"
```ts title="sdk.ts"
import Medusa from "@medusajs/js-sdk"
let MEDUSA_BACKEND_URL = "http://localhost:9000"