I have a C# desktop application which uses ADAL and the SharePoint Online CSOM to access SharePoint Online. The CSOM methods all work great, but sometimes I use a HttpWebRequest when I need to resolve a document ID URL to a file path (and I don't know which site or library the file is in). Even though I am setting the authorization header of the HttpWebRequest to the access token, the response's HTTP status is 401. Any suggestions on how to fix this?
I setup an AppRegistration in Azure as a native application with "Read and write items and lists in all site collections" permission. I didn't see any other applicable permissions that I would need to access the DocIdRedir.aspx page.
I am adding my ADAL token to a web request with the following properties:
Headers: Authorization: Bearer xxxxxxxx
The response I get back is a 401 Unauthorized with a "WWW-Authenticate" header. When I use a cookie container instead, everything works great.
So I am wondering if it is possible to use tokens with the DocIdRedir.aspx page?