SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.24k stars 1k forks source link

.Net Standard Authentication working but still unable to load projects in Project Online #5956

Open snakex64 opened 4 years ago

snakex64 commented 4 years ago

Category

Question

Not sure what I am not doing correctly. I followed the Using modern authentication with CSOM for .NET Standard documentation, but I still can't query the list of projects using the "ProjectContext". The authentication seems be to working, I get a token but when I try to "Load" context.Projects it doesn't load anything :

using var context = new CSOMDemo.AuthenticationManager().GetContext(new Uri($"https://{company}.sharepoint.com/sites/pwa"), email, password);
context.Load(context.Projects);
context.ExecuteQuery();

var project = context.Projects.First(); // crash, Sequence contains no elements

If I do the same thing but using the .Net Framework with SharePointOnlineCredentials, the same url, username and password works.

The permissions in the application in azure seems to be configured correctly since if I remove the SharePoint> AllSites.FullControl and then try to run the same code, I get a ServerUnauthorizedAccessException at the ExecuteQuery line.

I changed the ClientContext for a ProjectContext in the Authentication.GetContext method.

Is this a bug or am I missing something ?

Thanks,

Environment details (development & target environment)

msft-github-bot commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

anthonybutcher-sm commented 3 years ago

Having exactly the same issue

MudasirAshraf commented 3 years ago

The same issue and i know there would be still no answer