How to set "context.request.query" with password-less login with magic link using management API

how to set “context.request.query” with password-less login with magic link using management API.

here we are talking about Action’s context.

Hi @akgupta317,

Thanks for reaching out to the Auth0 Community!

Unfortunately, the context.request.query is a read-only property and cannot be updated. Could you please clarify what you intend to do here?

The equivalent property in Actions is the event.request.query property.

I look forward to your reply.

Thanks,
Rueben

1 Like

Hello guys ,
I also have another solution , and i am just suggesting you hope so it is beneficial for you let see-
To set “context.request.query” with password-less login with magic link using the Auth0 Management API, you can follow these steps:

  1. Create a new API token in your Auth0 dashboard by going to the “APIs” section, selecting your API, and clicking on the “Machine to Machine Applications” tab. From there, you can create a new token that has the necessary permissions to manage your Auth0 resources.
  2. Use the Management API to create a new passwordless connection by sending a POST request to the /api/v2/connections endpoint. In the request body, include the following JSON:

jsonCopy code

{
  "name": "my-passwordless-connection",
  "strategy": "email",
  "enabled_clients": ["my-client-id"]
}

Replace “my-passwordless-connection” with the name you want to give your connection, “email” with the strategy you want to use (in this case, email), and “my-client-id” with the ID of the client you want to enable for passwordless login.

  1. Generate a magic link for the user by sending a POST request to the /passwordless/start endpoint of the Management API. In the request body, include the following JSON:

perlCopy code

{
  "connection": "my-passwordless-connection",
  "email": "user@example.com",
  "send": "link",
  "authParams": {
    "response_type": "token",
    "redirect_uri": "https://my-app.com/callback",
    "state": "some-state",
    "scope": "openid profile email"
  }
}

Replace “my-passwordless-connection” with the name of the passwordless connection you created in step 2, “user@example.com” with the email address of the user you want to send the magic link to, and “https://my-app.com/callback” with the URL of your application’s callback endpoint. The “authParams” object contains the additional parameters that will be included in the authentication request, such as the response type, redirect URI, state, and scope.

  1. Once the user receives the magic link and clicks on it, they will be redirected to your application’s callback endpoint. The context object will contain the user’s information, including their email address, which you can access using “context.request.query.email” in your application’s code. Fragomen Connect Portal

Note that you may need to configure your application’s callback endpoint to handle the authentication response and extract the necessary information from the context object. You can find more information on how to do this in the Auth0 documentation. hope so it is useful for you.

thanks @rueben.tiow,

we want to pass some transactional or context-level data to action for that particular login request.

Detailed use-case :

let’s say there is a user as : testUser@123

there is a request to login/Authorize this user with an email link.

now there is some context attached to this request as
var request_Context ={
plan = A,
requested = 123
}

now, we want to pass this login request_context to Auth0 Actions, so that we can use this info
to perform some operations.

please let me know if you need more details.

note: this contextData is not user’s meta data, its data specific to a password-less login request
which we want to persist after successful passwordless magic link login.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Hi @akgupta317,

Thank you for your response.

You should be able to use an Auth0 Post Login Action to get the Passwordless magic link login’s context request in Actions by calling event.context.request.

Please let us know if you have any additional questions.

Thanks,
Rueben