gilbertchen / duplicacy

A new generation cloud backup tool
https://duplicacy.com
Other
5.12k stars 334 forks source link

google drive use direct link to google oauth page for generating access token #603

Open jorgeelmundoso opened 4 years ago

jorgeelmundoso commented 4 years ago

There is a oauth schema for installed apps, nicely implemented in https://github.com/gdrive-org/gdrive/blob/c3cbcceedd6beb1fcff30f06ea7be7c29558d181/handlers_drive.go#L393-L406

It's only a few lines of code, but it will allow to print a url:

Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=state

and scan the token from stdin without having to download the file, and without visiting a third party website like:

https://duplicacy.com/gcd_start

Same approach could be pushed to the web gui, just have an input text field to paste the token back in.

Of course you would need to come up with a place to store the token, could be pushed into the config.

This would improve usability and remove the need to trust https://duplicacy.com/gcd_start to not nick a token.

sasjafor commented 3 years ago

This sounds really good and it would remove the hassle with gcd-token files if the token is stored by duplicacy. And for the Web edition it could be encrypted with the rest of the config.

vmsh0 commented 1 year ago

I second this.

Some points that imho are relevant:

I'm happy to submit a PR about this and plan to do so, I hope I'll find the time to work on it in the coming days/weeks.

UPDATE: apologies, but after wasting ~5 hours trying and failing to build the project due to the use of the old Go build system and unversioned dependencies, I decided to abandon the endeavour. If anyone wishes to take time to help me with the build, I'm happy to resume work.