I am developing a native app (WinInet/C++) and after completing OAuth2 as described here and getting auth token, try to send any request to my SharePoint but get 401.

The site is SharePoint online (like https://mycompany-my.sharepoint.com), my app is registered in Azure AD.

401 response asks for X-Forms auth in the header, while I need OAuth since it has long-living token, allows several users being logged-in on the same application, gives more control on revocation and refreshing of the token.

enter image description here

  • Did you gave proper App Permission
    – Milind
    Aug 31, 2019 at 16:31
  • If you mean in Azure portal, yes, it's set to full access (set it for testing purpose). But I didn't register the app on SharePoint server specifically since expected usage is to run on customer's servers where I cannot register my app on every server.
    – andrii
    Sep 1, 2019 at 18:25
  • No, I mean Azure API. If you are going use graph API then you need to register Azure API in azure active directory blade
    – Milind
    Sep 1, 2019 at 18:59
  • I am not using graph API - I use some mix of CSOM and other older API since some customers still have old SP on-premise/local versions and I wouldn't like to have several implementations - old and new-like. I didn't really get what is registering Azure API in AAD blad :( How can I register API? In general, I followed steps described by the link in my question
    – andrii
    Sep 1, 2019 at 20:03
  • Firstly, The site is SharePoint online (like mycompany-my.sharepoint.com), my app is registered in Azure AD. It's a Onedrive URL, not a SharePoint site URL in Office 365. Sep 11, 2019 at 10:07

1 Answer 1


I have put it as answer as in comments I cannot add image.

Now over to your question, Documentation link which you gave clearly mention that you to register app on Azure. Please read documentation properly. If you can't then let me know I will come on chat and help you out.enter image description here

  • I have done it. If didn't I wouldn't be able to get auth token. But as I wrote, I do get auth token but it does not work with SP server
    – andrii
    Sep 3, 2019 at 11:09
  • go to jwt.ms and past your auth token and send us screen shot of the result
    – Milind
    Sep 3, 2019 at 11:20
  • sorry, "send us" - whom "us"? cannot put screenshot here
    – andrii
    Sep 3, 2019 at 21:25
  • Us me and other people who can help. To put screen shot edit your original question with screen shot
    – Milind
    Sep 4, 2019 at 6:43
  • Did you resolve the issue
    – Milind
    Sep 5, 2019 at 3:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.