This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
generated from beyondstorage/go-service-example
-
Notifications
You must be signed in to change notification settings - Fork 2
How to authorize gdrive API #17
Comments
Merged
gcs uses oauth2 too: https://github.com/beyondstorage/go-service-gcs/blob/master/utils.go#L99-L116 Maybe we can use the already authorized token to send API? Let the user decide how to generate the token files. (We can add another tool to help the user finish the job.)
|
Sorry but I don't realize we already have examples to do this. Let's update gdrive with what we did in gcs
|
Fixed in #18 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Background
Recently I'm working on authorizing gdrive API in different ways. This is because I found we can't really authorize it simply via API key.(It succeed, but can't do things like
Write
,Delete
)Ways to authorize
After a long search, I found there are two ways to do this:
Oauth2
If we use this, users will have to copy a link from terminal, and paste a secret code from web.
JSON Web Token
Though Google claims that:
I still found another way to do this from StackOverFlow
We can generate a JSON file, and initialize the service like
drive.NewService(ctx, option.WithCredentialsFile(jsonFilePath))
But there comes some problems: We can't access files created in
go-storage
, as they belong to the API account email (something like [email protected]
)Maybe there is a way to solve this, see https://stackoverflow.com/questions/12211859/i-cant-see-the-files-and-folders-created-via-code-in-my-google-drive, but it looks very wired. :-(
Other problems
Now we choose our way to authorize service by using pairs, but it likes we don't have a protocol for Oauth.
Summary
- How to initialize Storager by using OAuth2?( I mean, likepairs.WithCredential("api:abcdefg")
JSON Web Token
?( Personally I don't want to do this...The text was updated successfully, but these errors were encountered: