0

I'm writing a feature that uses an API implemented on top of the Microsoft/Azure stack. To access the service, I'm first required to fetch an OAuth2.0 token.

URL to get the token: https://login.microsoftonline.com/ten-ant-uuid-here/oauth2/v2.0/token

x-www-form-urlencoded params are:

  • grant_type: client_credentials
  • client_id: client_id_here
  • client_secret: client_secret_here
  • scope: api://scope-uuid-here/.default

After sending this request, I receive a JSON with the access_token field that consists the token. I can now use it in API Endpoint to retrieve required data.

I wanted to set up the Auth. Provider in Salesforce that utilizes this implementation in order to use it later as "Named Principal" Named Credential.

My config for of the Auth. Provider:

Unfortunately I got an error on Microsoft side ("No reply address is registered for the application."), when used the "Test-Only Initialization URL" that was generated after saving the Auth. Provider: https://sandbox-name.sandbox.my.salesforce.com/services/auth/test/Test

enter image description here

When setting this Auth. Provider as "Named Principal" for new Named Credential, I'm receiving the same error.

What I got from from Salesforce Docs is that this is a problem with the Callback URL and the one generated on Salesforce side should be used in Custom App in Azure Setup. Howerer, I don't have access to this app and I don't need to provide Callback URL when testing this service from my local Postman client app. I can actually hardcode this flow in Apex and it work's flawlessly.

So my question is: Is there a way to setup this integration with the usage of Auth. Provider or am I forced to implement it 'purely' in Apex, storing the app config (client key/secret, tenant ID ect.) in Custom Metadata / Custom Settings?

0

You must log in to answer this question.