HI there, I need to be able to allow users to paste in a google sheets URL in my app, and then read data from it. I can see the data if I make the sheet not-private, and use an API key. However, I also need to be able to read private sheets and write data back to them. Which means I have to use OAuth2.
Looking for some examples or good documentation. All the tutorials on YT for Unity and Sheets all use the API Key… because it’s easy.
Any help much appreciated.
There’s a fair number of Oauth2 packages on the Unity Asset Store. I haven’t used any of them myself, not even sure if any of them are useful, but at least that’s a thing to look at.
Thanks but not what I’m looking for.
Hi there. So I did find a package on GitHub that includes Google Sheets. So have been trying to implement but the documentation is non-existent so not having a lot of luck.
Here’s the package on Git:
https://github.com/cdmvision/authentication-unity
private void Start()
{
AuthorizationCodeFlow.Configuration config = new AuthorizationCodeFlow.Configuration();
config.clientId = "...";
config.clientSecret = "...";
config.redirectUri = "/";
var auth = new GoogleAuth(config);
testIt(auth);
}
private async void testIt(GoogleAuth auth)
{
var authenticationSession = new AuthenticationSession(auth, new StandaloneBrowser());
AccessTokenResponse accessTokenResponse = await authenticationSession.AuthenticateAsync();
}
And now in Console I get:
Making authorization request…
Getting authorization grant using browser login…
But then:
ArgumentNullException: Value cannot be null.
Parameter name: uriPrefix
So it wants a redirect URI. But I have no clue how to provide one. I’ve heard of this ‘deep linking’ method but not sure how to do it and my app is already open.
Doesn’t that come back in the response when you get a browser challenge??