Custom Function authentication and POST method

Hi @Andrea,

You do not need to build a webhook to perform http POST authentication with a custom-function.

Basically any provider can be authenticated via the following url:

 https://realm.mongodb.com/api/client/v2.0/app/<yourappid-abcde>/auth/providers/<provider type>/login

For custom function you can do:

curl --location --request POST 'https://realm.mongodb.com/api/client/v2.0/app/myapp-abcde/auth/providers/custom-function/login' \
  --header 'Content-Type: application/json' \
  --data-raw '{

   "username" : "myuser@exmaple.com"

  }'

This will result in a successful authentication and the access token to use for other services (eg. graphql).

Remember to change your appId and provide the relevant payload for the auth provider, in your case a username field.

Please let me know if you have any additional questions.

Best regards,
Pavel

2 Likes