Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Using CSOM with ADAL and uploading a file - Error 401 (Unauthorized)

$
0
0

Hi!

I have a request where I want to upload a file to  OneDrive for Business. but I don't want to ask for the user credentials (name and password). I use ADAL for this purpose. The login Works OK but when calling SaveBinary I get an error 401.

I show step by step what I do.

In the azure server, I go to "Azure Active Directory", then I go to "App registrations" and I click on "New application registration".

I enter this data:

Then I click on CREATE.

Now I click on Required permissions, then I click on Add, I click on Select an API.

Here I select "Office 365 SharePoint Online". I click on Select.

In Select permissions I add all permissions:

I click on Select. I now click on Done and I click on Grant permissions.

I will put my C# code in a next post (it does not allow me)

When I execute it. When calling SaveBinary I get a System.Net.WebException (The remote server returned an error: (401) Unauthorized)

The problem happens when calling SaveBinary.... if I modify the part of the code that does the login and I put the credentials (user name and password), SaveBinary Works OK. So it smells like if there is something I missed...

Does this schema work OK with OneDrive for Business? Maybe it can work OK with SharePoint Online but not with OneDrive for Business...

Thanks



Viewing all articles
Browse latest Browse all 7589

Trending Articles