Im developing a React Expo app where im trying to access a BC page i've created.
Im able to get access to the page in Postman, but i'm unable to get access in my Expo app.
Here is my code:
I followed you video and got a successful response from Postman, but somehow I still can't get it to work in my app. Using https://jwt.io I can see that the access token from Postman gives access to my tenant, but the access token from my app gives me access to Microsoft Graph.
This is the response I get in the terminal:
<error xmlns="docs.oasis-open.org/.../code><message>The credentials provided are incorrect</message></error>
Have you added in Azure active directly in BC?
Also please refer the below link for app registration in Azure.
Do you mean like this?
const response = await fetch(`login.microsoftonline.com/.../token`, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body:
"grant_type=client_credentials" +
"&client_id=xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx" +
"&scope=api.businesscentral.dynamics.com/.default" +
"&client_secret=xxxxx~xxxxxxxxxxxxxxxxxxxx~xxxxxxxxxxxxx"
});
Because that didn't change anything
Also Create an entry in Azure Active directory application page in BC and enabled with your custom app.
Thanks.
Please use below syntax for your Body part
grant_type=client_credentials
&client_id=413ac35b-e0b6XXXXXXXXXXXXX-72f94d476bf8
&scope=api.businesscentral.dynamics.com/.default
&client_secret=9w38Q~PJoLaAsL.ObXXXXXXXXXXXLqIRpGAAb95blu
header part
Content-Type - application/x-www-form-urlencoded
Not sure if this guide will help, but it may relate?
businesscentralgeek.com/how-to-use-postman-to-connect-with-business-central-apis
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,232 Super User 2024 Season 2
Martin Dráb 230,064 Most Valuable Professional
nmaenpaa 101,156