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
@@ -110,7 +110,7 @@ The third-party service authentication method requires using the `authenticate`
```ts
const { success, authIdentity, location } = await authModuleService.authenticate(
"emailpass",
"google",
// passed to auth provider
{
// ...
@@ -134,6 +134,21 @@ For example, when using the `google` provider, the `location` is the URL that th
![Diagram showcasing the first part of the third-party authentication flow](https://res.cloudinary.com/dza7lstvk/image/upload/v1711374847/Medusa%20Resources/third-party-auth-1_enyedy.jpg)
### Overriding Callback URL
The Google and GitHub providers allow you to override their `callbackUrl` option during authentication. This is useful when you redirect the user after authentication to a URL based on its actor type. For example, you redirect admin users and customers to different pages.
```ts
const { success, authIdentity, location } = await authModuleService.authenticate(
"google",
// passed to auth provider
{
// ...
callback_url: "example.com"
}
)
```
### validateCallback
Providers handling this authentication flow must implement the `validateCallback` method. It implements the logic to validate the authentication with the third-party service.