Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions docs/getting-started/integrate-auth/14_auth-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ To create the client using the Ory Console:

1. Sign in to your Ory Network account.
2. Create or select a project.
3. Go to **OAuth 2**, select [**OAuth2 Clients**](https://console.ory.sh/projects/current/oauth), and select [**Create OAuth 2.0 Client**](https://console.ory.sh/projects/current/oauth/create).
3. Go to **OAuth 2**, select [**OAuth2 Clients**](https://console.ory.com/projects/current/oauth), and select [**Create OAuth 2.0 Client**](https://console.ory.com/projects/current/oauth/create).
4. Select **Server App**.
5. Enter a client name, for example, "NextAuth / Auth.js Example."
6. Ensure the following scopes are selected:
Expand All @@ -74,7 +74,7 @@ To create the client using the Ory Console:
7. Add the following to **Redirect URIs**:

```
http://localhost:3000/api/auth/callback/ory
http://localhost:3000/auth/callback/ory
```

8. Add the following to **Post Logout Redirect URIs**:
Expand All @@ -94,7 +94,7 @@ To create the client using the Ory Console:
To create the client using the Ory CLI, run the following command:

```shell
export ORY_PROJECT_ID= # Take this value from https://console.ory.sh/projects/current/get-started
export ORY_PROJECT_ID= # Take this value from https://console.ory.com/projects/current/get-started
ory create oauth2-client --project $ORY_PROJECT_ID \
--redirect-uri http://localhost:3000/api/auth/callback/ory \
--name "NextAuth / Auth.js Example" \
Expand All @@ -115,8 +115,8 @@ Update your `.env.local` file to match the example:
<CodeFromRemote lang="env" src="https://github.com/ory/next-auth-example/blob/main/.env.local.example" />
```

Also add your Ory SDK URL. You can find it in the [**Get started**](https://console.ory.sh/projects/current/get-started) section
of the Ory Console.
Also add your Ory SDK URL as `ORY_SDK_URL`. You can find it in the
[**Get started**](https://console.ory.com/projects/current/get-started) section of the Ory Console.

## Test your application

Expand Down Expand Up @@ -159,5 +159,21 @@ The request is missing a required parameter, includes an invalid parameter value
The 'redirect_uri' parameter does not match any of the OAuth 2.0 Client's pre-registered redirect URLs.
```

Make sure that the redirect URL exactly matches the one registered in Ory. Use the browsers network tab to inspect requests made
Make sure that the redirect URL exactly matches the one registered in Ory. Use the browser's network tab to inspect requests made
to `/oauth2/auth`.

### Resolve UntrustedHost errors

If you receive an error like:

```
[auth][error] UntrustedHost: Host must be trusted. URL was: http://localhost:3000/auth/signin?callbackUrl=...
```

Add the following to your `.env.local` file:

```
AUTH_TRUST_HOST=1
```

This allows Auth.js to trust the localhost host during development. For production, make sure to configure trusted hosts properly.
Loading