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 authored and GitHub committed 2025-09-16 18:39:56 +03:00
1 parent 92102dcafb
commit 1c4f7bd53a
3 files changed
+46 -42

No files matched your search

+23 -21
View File
@@ -24900,7 +24900,7 @@ The Google Auth Module Provider allows you to authenticate users with their Goog
### Prerequisites ### Prerequisites
- [Create a project in Google Cloud.](https://cloud.google.com/resource-manager/docs/creating-managing-projects) - [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`: 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({ module.exports = defineConfig({
// ... // ...
modules: [ modules: [
// ...
{ {
// ... resolve: "@medusajs/medusa/auth",
[Modules.AUTH]: { dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
resolve: "@medusajs/medusa/auth", options: {
dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER], providers: [
options: { // other providers...
providers: [ {
// other providers... resolve: "@medusajs/medusa/auth-emailpass",
{ id: "emailpass",
resolve: "@medusajs/medusa/auth-google", },
id: "google", {
options: { resolve: "@medusajs/medusa/auth-google",
clientId: process.env.GOOGLE_CLIENT_ID, id: "google",
clientSecret: process.env.GOOGLE_CLIENT_SECRET, options: {
callbackUrl: process.env.GOOGLE_CALLBACK_URL, 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) ### Admin (Medusa project)
```ts title="src/admin/lib/config.ts" ```ts title="src/admin/lib/sdk.ts"
import Medusa from "@medusajs/js-sdk" import Medusa from "@medusajs/js-sdk"
export const sdk = new Medusa({ export const sdk = new Medusa({
@@ -45047,7 +45049,7 @@ export const sdk = new Medusa({
### Admin (Medusa Plugin) ### Admin (Medusa Plugin)
```ts title="src/admin/lib/config.ts" ```ts title="src/admin/lib/sdk.ts"
import Medusa from "@medusajs/js-sdk" import Medusa from "@medusajs/js-sdk"
export const sdk = new Medusa({ export const sdk = new Medusa({
@@ -45061,7 +45063,7 @@ export const sdk = new Medusa({
### Storefront ### Storefront
```ts title="config.ts" ```ts title="sdk.ts"
import Medusa from "@medusajs/js-sdk" import Medusa from "@medusajs/js-sdk"
let MEDUSA_BACKEND_URL = "http://localhost:9000" let MEDUSA_BACKEND_URL = "http://localhost:9000"
@@ -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" 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" 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({ module.exports = defineConfig({
// ... // ...
modules: [ modules: [
// ...
{ {
// ... resolve: "@medusajs/medusa/auth",
[Modules.AUTH]: { dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
resolve: "@medusajs/medusa/auth", options: {
dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER], providers: [
options: { // other providers...
providers: [ {
// other providers... resolve: "@medusajs/medusa/auth-emailpass",
{ id: "emailpass",
resolve: "@medusajs/medusa/auth-google", },
id: "google", {
options: { resolve: "@medusajs/medusa/auth-google",
clientId: process.env.GOOGLE_CLIENT_ID, id: "google",
clientSecret: process.env.GOOGLE_CLIENT_SECRET, options: {
callbackUrl: process.env.GOOGLE_CALLBACK_URL, clientId: process.env.GOOGLE_CLIENT_ID,
}, clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackUrl: process.env.GOOGLE_CALLBACK_URL,
}, },
], },
}, ],
}, },
}, },
], ],
+3 -3
View File
@@ -44,7 +44,7 @@ For admin customizations, create this file at `src/admin/lib/config.ts`.
<CodeTabs group="sdk-project"> <CodeTabs group="sdk-project">
<CodeTab label="Admin (Medusa project)" value="admin-medusa-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" import Medusa from "@medusajs/js-sdk"
export const sdk = new Medusa({ export const sdk = new Medusa({
@@ -59,7 +59,7 @@ export const sdk = new Medusa({
</CodeTab> </CodeTab>
<CodeTab label="Admin (Medusa Plugin)" value="admin-medusa-plugin"> <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" import Medusa from "@medusajs/js-sdk"
export const sdk = new Medusa({ export const sdk = new Medusa({
@@ -74,7 +74,7 @@ export const sdk = new Medusa({
</CodeTab> </CodeTab>
<CodeTab label="Storefront" value="storefront"> <CodeTab label="Storefront" value="storefront">
```ts title="config.ts" ```ts title="sdk.ts"
import Medusa from "@medusajs/js-sdk" import Medusa from "@medusajs/js-sdk"
let MEDUSA_BACKEND_URL = "http://localhost:9000" let MEDUSA_BACKEND_URL = "http://localhost:9000"