authenticate - Auth Module Reference

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

NoteYou should only use this methods when implementing complex customizations. For common cases, check out available workflows instead.

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:

Code
1const { success, authIdentity, location, error } =2  await authModuleService.authenticate("emailpass", {3    url: req.url,4    headers: req.headers,5    query: req.query,6    body: req.body,7    protocol: req.protocol,8  } as AuthenticationInput)

Parameters#

providerstring
The ID of the provider to authenticate the user with.
The data to pass to the provider to authenticate the user.

Returns#

PromisePromise<AuthenticationResponse>
The details of the authentication result.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break