I want to get a SP2013 list and I can't use CSOM. I've registered my app (a cmd test app, not a SP hosted one) on Sharepoint and have a clientId and clientSecret.
But when I submit the Authorize Url that I built:
https://mysite.sharepoint.com/_layouts/15/OAuthAuthorize.aspx?client_id=<myclientId>&scope=list.read&response_type=code&redirect_uri=https%3A%2F%2Fwww.google.com
I get a http403 on fiddler.
or
when I request it from a browser I get redirected to:
https://www.google.com/?error=invalid_scope&error_description=The%20scope%20list%2Eread%20is%20not%20valid%2E
which is my redirect_uri but with the error "invalid scope". I've tried to use the scope uri (instead of the alias) and got the same response.
Note that I'm also authenticaded when I make the request from the browser. Otherwise I get redirected to the login page.
How can I get an access token to make REST requests to Sharepoint?
Here is a longer description of what I'm trying to do:
I’ve got a sharepoint list at https://mysite.sharepoint.com/
. (the location is actually: https://mysite.sharepoint.com/_layouts/15/start.aspx#/Lists/TestTasksList
)
And I want to query it from an android app. So far I have and android app built using xamarin to create tasks. I can’t use the client side object model. So the only option is using the Rest Api. I have tried to create a simple .net cmd line app to query the rest api but I can’t find a way to authenticate. I think I need to use OAuth but even after getting the clientId and clientsecret I can’t manage to make requests. I can’t get an access token.
Most code samples that I found are for sharepoint applications to be deployed in the cloud and they seem to ignore the authentication bit (or just using default credentials).
I managed to authenticate and query the list using the CSOM in a .net cmd app. But I can’t find a way to do it using the rest api. I know we can use the legacy web services (from SP2010) but that won’t work as a long term solution.
So the bottom line is querying a list in Office 365 from a console app using the REST api.