如何让其他人使用googleapi阅读和编辑Google表格(不与他们共享),而不必下载凭据?

I am a beginner trying out api for fun.

The problem is, lets say, I want to write a simple windows program with golang to let my friends read and edit one of the sheets saved on my google drive. How can I do this without having them download a credential file?

What I want it to do is simply redirect them to the Oauth Page right away, and if their email address is one recognized by the app it will grant them access to that google sheet.

What i think you need is to integrate your go app with Oauth protocol. More specifically, with the Google provider.

This is mainly 3 steps:

  1. add the oauth client to your application

    something like this: https://github.com/golang/oauth2

    See their docs on how to do it.

  2. go to google dev documentation and see how to integrate google auth flow into the client: https://developers.google.com/identity/protocols/OAuth2

    I'm not sure if google has something more specific for google drive integration and/or go-lang client in particular. Please do some searching.

  3. make the glue code on your go app so that the user can interact with this (the login button (or command, if it is terminal based), error messages, logout, etc)

More questions will appear when you start to do this, however it is a great example to learn Oauth as well.

General guidelines:

  • https all the queries or oauth is basically useless
  • oatuh has many auth-flows and you must choose which one(s) you support. use whatever google documentation recommends for m2m scenario (machine 2 machine)
  • log errors so that your friends can send you a log file for you to debug issues
  • maybe set some feature flag so that you can simply disable this feature to run/test localhost ? maybe useful? you decide.