How to authenticate Google Drive without requiring the user to copy/paste auth code?

前端 未结 3 504
旧时难觅i
旧时难觅i 2021-02-01 09:44

I\'m playing around with the DriveCommandLine applicaiton to learn the Drive API a bit. I\'m just wondering if it is possible to authenticate my desktop application with Google

3条回答
  •  有刺的猬
    2021-02-01 10:41

    The command line samples were written for simplicity, not necessarily the best user experience. In this case, they're running as local apps and are using the installed app flow for OAuth 2.0. That flow does have a mode where the redirect_uri can point to localhost, but it requires starting up a temporary web server to receive the redirect. Rather than complicate the sample, it uses the OOB mode which requires copy/pasting the code.

    If you're building a desktop app, I'd encourage going the route of redirecting to localhost as it is a better UX.

    See https://developers.google.com/accounts/docs/OAuth2InstalledApp for more info.

提交回复
热议问题