web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

OAuth 2.0 token for D365 F&O Odata Rest call

(0) ShareShare
ReportReport
Posted on by 30

Hi,

  I am trying to invoke D365 F&O Odata rest API call with grant type as authorization_code but I keep getting response code as 401 (Unauthorized).

  Has anyone tried Authorization Code Grant Flow for Dynamics 365 F&O before? If yes, please share the link or step to do it?

  FYI, I have tried calling Rest API with client type as "Client credential" as mentioned in below link and its working fine.

  docs.microsoft.com/.../third-party-service-test

  However ask is to integrate it via OA Auth 2.0 for better security

Regards,

Satyajeet Kumar

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Satyajeet,.

    Have you created an App Id and configured it in D365 F&O. Please check the permissions assigned to the App Id as well. Please follow this link for the steps.

  • satyajeet Kumar New Profile Picture
    30 on at

    Hi Gunjan,

     Yes, Appid has been registered in Azure along with necessary permission given to same app.

     Just to clarify, I am able to generate the bearer token for user. However, problem is calling Rest OData API call via that token gives response code as 401 unauthorized.

    One more point to add in D365 I have link appid to "Admin" user. I guess that should be fine.

    Thanks,

    Satyajeet

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Satyajeet,

    Admin user should be fine. Could you please share a screenshot of the permissions granted for the application Id?

  • satyajeet Kumar New Profile Picture
    30 on at

    pastedimage1601219279896v1.png

  • satyajeet Kumar New Profile Picture
    30 on at

    Hi Gunjan,

    Please see the screenshot below.

    Also, any input if expose API set up also needed for app?

    FYI, I was checking the token in jwt.io , scp shows only user.read permission of Microsoft graph api.

    Not other permission of Dynamics ERP. Do you see that as an issue?

    Regards,

    Satyajeet

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Satyajeet,

    Sorry, I didn't understand what you are trying to do when you say this - "Also, any input if expose API set up also needed for app?" Please elaborate a little more on this.

    The permissions are correct as per the documentation. But we had faced an issue recently with these permissions and had to add one more (as per our call with MS support). I will try to find that out as I don't remember exactly which one it was. 

    Could you please verify if the admin user has privileges on Azure as well?

  • satyajeet Kumar New Profile Picture
    30 on at

    Hi Gunjan,

    If you go app registration detail page it has link called "Expose API". My question was anything needs to be done for same.

    ERP admin user is linked to my organization's email address and I am the owner of subscription where D365 F&O has been deployed.

    Does it suffice? Or any other set up needed for admin user to have privileges on Azure?

    Regards,

    Satyajeet Kumar

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Satyajit,

    We haven't exposed the API before, so don't think that is needed.

    Could you please change the Azure app registration from admin user to your user Id In D365 F&O? Alternatively, you could set your user up as the admin as well since you are the owner of the subscription where Azure is hosted.

  • satyajeet Kumar New Profile Picture
    30 on at

    Hi Gunjan,

      I can't edit the email of Admin user , may be due to the fact that I deployed D365 on Azure

      subscription.

      Plus, system not allowing to create a new admin like user having my email address.

      Anyway, we will try raise support ticket with MS for same issue.

    Regards,

    Satyajeet

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Satyajeet,

    You don't need to create another admin. I hope you are logging in with your email Id and not the admin user. In that case, you can assign change the user in the form Azure active directory application form in D365 F&O.

    You can also change the admin email Id using the admin user provisioning tool, if you have deployed a Dev Box. But, since this is in Azure, let's not do that right now.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans