Skip to main content
Skip to main content

authenticate - Auth Module Reference

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

This method is used to authenticate a user using a provider. The authenticate method of the underlying provider is called, passing it the providerData parameter as a parameter. The method returns the data returned by the provider.

Refer to this guide to learn more about the authentication flows.

Example

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

const { success, authUser, location, error } =
await authModuleService.authenticate("emailpass", {
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 authenticate the user with.
providerDataAuthenticationInputRequired
The data to pass to the provider to authenticate the user.

Returns

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