Skip to content

Commit 1c4f7bd

Browse files
authored
docs: fixes to JS SDK + auth provider guides (medusajs#13526)
* docs: fixes to JS SDK + auth provider guides * more fixes * fix lint error
1 parent 92102dc commit 1c4f7bd

File tree

3 files changed

+46
-42
lines changed

3 files changed

+46
-42
lines changed

www/apps/book/public/llms-full.txt

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24900,7 +24900,7 @@ The Google Auth Module Provider allows you to authenticate users with their Goog
2490024900
### Prerequisites
2490124901

2490224902
- [Create a project in Google Cloud.](https://cloud.google.com/resource-manager/docs/creating-managing-projects)
24903-
- [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)
24903+
- [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)
2490424904

2490524905
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`:
2490624906

@@ -24912,25 +24912,27 @@ import { Modules, ContainerRegistrationKeys } from "@medusajs/framework/utils"
2491224912
module.exports = defineConfig({
2491324913
// ...
2491424914
modules: [
24915+
// ...
2491524916
{
24916-
// ...
24917-
[Modules.AUTH]: {
24918-
resolve: "@medusajs/medusa/auth",
24919-
dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
24920-
options: {
24921-
providers: [
24922-
// other providers...
24923-
{
24924-
resolve: "@medusajs/medusa/auth-google",
24925-
id: "google",
24926-
options: {
24927-
clientId: process.env.GOOGLE_CLIENT_ID,
24928-
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
24929-
callbackUrl: process.env.GOOGLE_CALLBACK_URL,
24930-
},
24917+
resolve: "@medusajs/medusa/auth",
24918+
dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
24919+
options: {
24920+
providers: [
24921+
// other providers...
24922+
{
24923+
resolve: "@medusajs/medusa/auth-emailpass",
24924+
id: "emailpass",
24925+
},
24926+
{
24927+
resolve: "@medusajs/medusa/auth-google",
24928+
id: "google",
24929+
options: {
24930+
clientId: process.env.GOOGLE_CLIENT_ID,
24931+
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
24932+
callbackUrl: process.env.GOOGLE_CALLBACK_URL,
2493124933
},
24932-
],
24933-
},
24934+
},
24935+
],
2493424936
},
2493524937
},
2493624938
],
@@ -45033,7 +45035,7 @@ For admin customizations, create this file at `src/admin/lib/config.ts`.
4503345035

4503445036
### Admin (Medusa project)
4503545037

45036-
```ts title="src/admin/lib/config.ts"
45038+
```ts title="src/admin/lib/sdk.ts"
4503745039
import Medusa from "@medusajs/js-sdk"
4503845040

4503945041
export const sdk = new Medusa({
@@ -45047,7 +45049,7 @@ export const sdk = new Medusa({
4504745049

4504845050
### Admin (Medusa Plugin)
4504945051

45050-
```ts title="src/admin/lib/config.ts"
45052+
```ts title="src/admin/lib/sdk.ts"
4505145053
import Medusa from "@medusajs/js-sdk"
4505245054

4505345055
export const sdk = new Medusa({
@@ -45061,7 +45063,7 @@ export const sdk = new Medusa({
4506145063

4506245064
### Storefront
4506345065

45064-
```ts title="config.ts"
45066+
```ts title="sdk.ts"
4506545067
import Medusa from "@medusajs/js-sdk"
4506645068

4506745069
let MEDUSA_BACKEND_URL = "http://localhost:9000"

www/apps/resources/app/commerce-modules/auth/auth-providers/google/page.mdx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The Google Auth Module Provider allows you to authenticate users with their Goog
1919
link: "https://cloud.google.com/resource-manager/docs/creating-managing-projects"
2020
},
2121
{
22-
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.",
22+
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.",
2323
link: "https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred"
2424
}
2525
]}
@@ -35,25 +35,27 @@ import { Modules, ContainerRegistrationKeys } from "@medusajs/framework/utils"
3535
module.exports = defineConfig({
3636
// ...
3737
modules: [
38+
// ...
3839
{
39-
// ...
40-
[Modules.AUTH]: {
41-
resolve: "@medusajs/medusa/auth",
42-
dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
43-
options: {
44-
providers: [
45-
// other providers...
46-
{
47-
resolve: "@medusajs/medusa/auth-google",
48-
id: "google",
49-
options: {
50-
clientId: process.env.GOOGLE_CLIENT_ID,
51-
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
52-
callbackUrl: process.env.GOOGLE_CALLBACK_URL,
53-
},
40+
resolve: "@medusajs/medusa/auth",
41+
dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
42+
options: {
43+
providers: [
44+
// other providers...
45+
{
46+
resolve: "@medusajs/medusa/auth-emailpass",
47+
id: "emailpass",
48+
},
49+
{
50+
resolve: "@medusajs/medusa/auth-google",
51+
id: "google",
52+
options: {
53+
clientId: process.env.GOOGLE_CLIENT_ID,
54+
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
55+
callbackUrl: process.env.GOOGLE_CALLBACK_URL,
5456
},
55-
],
56-
},
57+
},
58+
],
5759
},
5860
},
5961
],

www/apps/resources/app/js-sdk/page.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ For admin customizations, create this file at `src/admin/lib/config.ts`.
4444
<CodeTabs group="sdk-project">
4545
<CodeTab label="Admin (Medusa project)" value="admin-medusa-project">
4646

47-
```ts title="src/admin/lib/config.ts"
47+
```ts title="src/admin/lib/sdk.ts"
4848
import Medusa from "@medusajs/js-sdk"
4949

5050
export const sdk = new Medusa({
@@ -59,7 +59,7 @@ export const sdk = new Medusa({
5959
</CodeTab>
6060
<CodeTab label="Admin (Medusa Plugin)" value="admin-medusa-plugin">
6161

62-
```ts title="src/admin/lib/config.ts"
62+
```ts title="src/admin/lib/sdk.ts"
6363
import Medusa from "@medusajs/js-sdk"
6464

6565
export const sdk = new Medusa({
@@ -74,7 +74,7 @@ export const sdk = new Medusa({
7474
</CodeTab>
7575
<CodeTab label="Storefront" value="storefront">
7676

77-
```ts title="config.ts"
77+
```ts title="sdk.ts"
7878
import Medusa from "@medusajs/js-sdk"
7979

8080
let MEDUSA_BACKEND_URL = "http://localhost:9000"

0 commit comments

Comments
 (0)