The .NET client libraries for Google Sheets API have not been updated since Jun 2013, and so cannot be added to a Windows Phone 8.1 application. However, Google has published an Auth NuGet package that works with Google Drive (and other Google services) and does support Windows Phone 8.1.
In the example for using OAuth 2 with Windows Phone 8.1, they demonstrate requesting DriveService.Scope.DriveReadonly
as a way to list the files available in Google Drive. However, I cannot find any similarly-named constants for Google Sheets, and there does not appear to be any Google Docs-related NuGet packages.
Can I use GoogleWebAuthorizationBroker.AuthorizeAsync
to also request app access to Google Sheets?
Yes!
The Google Sheets API documentation says that the "scope information for the Google Sheets API" is located at https://spreadsheets.google.com/feeds
.
Updating the sample (Step 6c) to
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
new Uri("ms-appx:///Assets/client_secrets.json"),
new[] { DriveService.Scope.DriveReadonly,
// Add our new scope here...
"https://spreadsheets.google.com/feeds" },
"app-name",
CancellationToken.None);
will give the application access to Google Sheets.
Unfortunately, after that you have to make the call to the Sheets API manually, so remember to include
v=3.0
in the query string itself or GData-Version: 3.0
as a header (link).Authorization
header in the form of Bearer {AccessToken}
. The AccessToken
be grabbed from
credential.Token
in AuthenticateAsync
after GoogleWebAuthorizationBroker.AuthorizeAsync
returns.(service.HttpClientInitializer as Google.Apis.Auth.OAuth2.UserCredential).Token
.