Auth0 Home Blog Docs

Unable to send context.accessToken

I have created a rule that sends an HttpPost to my API. My API endpoint is protected, meaning that I want to authenticate the request. I am trying to send the user’s access token in this HttpPost request to my API. I am having difficulty getting that to work - the bearer token is coming across from the rule, but it doesn’t look like the one that is returned from a successful login request (comparing them using JWT.io), and it doesn’t pass my authorization. The variable that I am using is context.accessToken.

My reasoning for doing this is to keep Auth0’s user.email_verified property in-sync with my application’s user setting that is related to this. If there is a better way to do this, please let me know that also.

Hi @wikoenig,

To confirm, you are trying to call your custom API from within a rule, and you are using the context.accessToken object and it is not working?

If this is the case, it is because context.accessToken is an object used for configuring the access token objects.

You will want to request an access token from the rule with your API as the audience, and then send that access token.

You should register a M2M application called Rules, and have your API registered in APIs. You can see an example of how to request an access token for your API in Node (which powers Rules), by going to the dashboard and navigating to APIs > {YOUR API} > Test > Node.JS.

Let me know if I missed something.

Thanks,
Dan

1 Like

This is very helpful Dan, thank you for your help.

Let us know if you have any more questions!