dosrmo0442 2019-03-05 18:35
浏览 182

如何让其他人使用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.

  • 写回答

1条回答 默认 最新

  • doutuohan6606 2019-03-05 18:54
    关注

    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.
    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能