Google-drive example: oauth2callback not found

2019-05-23 03:20发布

问题:

I need a little help with the C# example program of Google-Drive...

I used this so-called "tutorial"/"example":
https://developers.google.com/drive/examples/dotnet

And the code from here:
https://code.google.com/p/google-drive-sdk-samples/source/checkout

I uploaded my (only slightly modified) sourcecode here in case anybody doesn't have Mercurial (I didn't have Mercurial and no admin rights to install it either, and Mercurial is the only way to get the sourcecode...):
http://verzend.be/elt0k13enraw/DrEdit.rar.html

I always get

"Ressource cannot be found"

Requested URL: /oauth2callback

I don't find this astonishing, as no oauth2callback controller or handler is implemented...

I tried adding a Controller called oauth2callbackController and redirecting to another action in oauth2callbackController.Index, doing

return new RedirectResult("/about/about");

But that only creates a NULL-reference exception.

So i figured, maybe the wrong controller and redirected to

return new RedirectResult("/drive/Index");

But that only creates an infinite loop of redirect -> allow -> redirect - allow -> etc.

BTW, the config to change the API key + REDIRECT_URI is in

Models\ClientCredentials.cs

Note:
The problem aren't my modifications.
The sample also didn't work unmodified, with the exact same error.
All I did was removing EntityFramwork references, and throwing "Not implemented exception" when a method using entity was called.

Edit:
Additional information:
What I really wanted to do in the first place is to write a console service that exports my database, LZMA-compresses the exported content, encrypts that with OpenPGP, and uploads the database of my server to Google drive every day at 24:00 o'clock, without any user input.

I got export working without a problem, i got the LZMA compression working without a problem, I got the encryption with PGP working without a problem. After the end of the working day (grrrr), when I was at home, I was even able to download the example-code with the mercurial installed on my Linux-machine at home, and bring it on the windows machine using SMB...

But now I can't get the sample for the Google-drive SDK working...
And moreover, what I really need is an example for a console service/daemon, not a web-application. When I created the API key, I saw one could create a key for a service, but there is no example on how to write a Google-Drive service (console application), and no useful documentation as well (yea there is a reference, but it's only a reference, IntelliSense provides about the same)...

回答1:

When configuring your app in the API Access tab of the APIs Console, you had to set the root (/) of your web server as the redirect URI and not /oauth2callback.

Assuming that your app is published at www.example.com, just go back to the APIs Console and set it to www.example.com instead of www.example.com/oauth2callback