Skip to main content
Skip to main content

validateCallback - Auth Module Reference

This documentation provides a reference to the validateCallback method. This belongs to the Auth Module.

When authenticating users with a third-party provider, such as Google, the user performs an action to finish the authentication, such as enter their credentials in Google's sign-in form.

In those cases, you must create an API route or endpoint that's called by the third-party provider when the user finishes performing the required action.

In that API route, you can call this method to validate the third-party provider's callback and authenticate the user.

Learn more about this authentication flow in this guide.

Example

The following example is in the context of an API route, where req is an instance of the MedusaRequest object:

const { success, authUser, error, successRedirectUrl } =
await authModuleService.validateCallback("google", {
url: req.url,
headers: req.headers,
query: req.query,
body: req.body,
authScope: "admin",
protocol: req.protocol,
} as AuthenticationInput)

Parameters

providerstringRequired
The ID of the provider to use to validate the callback.
providerDataAuthenticationInputRequired
The data to pass to the provider to validate the callback.

Returns

PromisePromise<AuthenticationResponse>Required
The details of the authentication result.
Was this section helpful?