I'm working on a tool to access a google spreadsheet via .net. It worked with the old authentication way till google shut them down. Now I reworked to to work with OAuth2 and generated a valid access token.
Issue: even with the access token I get a Bad Request 400 as soon as I try to get the spreadsheet.
Here the code how I setup the service and build the query:
var documentService = new DocumentsService("documents");
var requestFactory = new GDataRequestFactory(null);
requestFactory.CustomHeaders.Add("Authorization: Bearer " + accessToken);
documentService.RequestFactory = requestFactory;
var query = new SpreadsheetQuery { Title = name };
var feed = documentService.Query(uri);
I also tried using the SpreadsheetsService instead as well as adding the access token directly to the query. Then the Uri of the query looks like this:
https://docs.google.com/feeds/default/private/full?category=spreadsheet&title={speadsheetName}&access_token={access_token}
Either way I keep getting the "Bad Request 400" response. Can anyone help me to figure out what goes wrong here?
Thanks!
EDIT: Since to code to access the spreadsheet didn't change by the update to OAuth2 and the access token is valid my best guess is that the service user/developer project misses some permission or something like this. But no idea where to fix that.
EDIT-2: I figured out that the access token works well with new api url's but does not seam to work with old api calls. Unfortunately I can't use the new Google SDK in my environment since I'm restricted to .NET 3.5 or lower. Maybe there is a option to enable the service user to use the old api calls or something like that?