Request and use a Management API token from a Flutter App


We need to allow our Flutter application to save a property in the user_metadata when the application starts.
I understand that this is a task to be done with the Management API and that in order for the Flutter application to be able to write in the user_metadata the client has to request a Management API access token.

I found no information on how to request this token, the closest thing is this page in the documentation that has no example and no explanation on how to retrieve this token:

Can anyone provide an example on how to request this token from a Flutter app?
Even a generic CURL request would be helpful to understand what endpoint to call with which parameters.
We understand that this is not a best practice but we see no security issue with our application in doing this.

Hi @francesco1 ,

Welcome to the Auth0 Community!

If I understand correctly, you want to request the access token and use the access token to make changes in the user_metadata.

We can get the access token by making the POST request to the /oauth/token endpoint.

For example, for the client credential flow, here is the curl request:

curl --request POST \
  --url 'https://YOUR_DOMAIN/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'audience=API_IDENTIFIER&grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET'

Here is the screenshot of my testing in Postman. Hope this helps!

1 Like