I'm trying generate an OAuth access token via the Google .Net GData Client Library. I've been using the instructions in http://code.google.com/apis/gdata/docs/auth/oauth.html as a guide and everything's been working up until I attempt calling OAuthUtil.GetAccessToken( parameters )
at which point I receive a "(400) Bad Request" web exception.
Unfortunately, it's not telling me anything about why it's a bad request. So, I'm kinda baffled about this. The only idea I have is that, because I'm using a localhost
url it's not working (though I have registered the url in the Google API Console and it seemed to be okay to do so).
Any ideas what I'm doing wrong here and what I should be doing to make it right?
The OAuthParameters
object is constructed like so (sensitive data is censored, hope that doesn't make it hard to answer):
BaseProperties:
oauth_consumer_key: <CLIENT_KEY>,
oauth_nonce: <NONCE>
oauth_signature_method: HMAC-SHA1
oauth_timestamp: 1330440325
oauth_token: <TOKEN>
oauth_verifier: <VERIFIER>
Callback: "http://localhost:57381/subscription_auth.aspx?c=google.calendar"
ConsumerKey: <CLIENT_KEY>
ConsumerSecret: <CLIENT_SECRET>
ExtraProperties
oauth_consumer_secret: <CLIENT_SECRET>
scope: https://docs.google.com/calendar/feeds/
oauth_callback: http://localhost:57381/subscription_auth.aspx?c=google.calendar
Nonce: <NONCE>
Scope: "https://docs.google.com/calendar/feeds/"
Signature: NULL
SignatureMethod: "HMAC-SHA1"
Timestamp: "1330440325"
Token: <TOKEN>
TokenSecret: NULL -- No Token Secret was returned from the callback.
Verifier: <VERIFIER>
This translates into headers for the web response which are like so:
Authorization: OAuth oauth_version="1.0",
oauth_nonce=<NONCE>,
oauth_timestamp="1330441324",
oauth_consumer_key=<CLIENT_KEY>,
oauth_verifier=<VERIFIER>,
oauth_token=<TOKEN>,
oauth_signature_method="HMAC-SHA1",
oauth_signature=<SIGNATURE>
(line breaks added for readability)
NOTE: The above redacted values are encoded correctly where relevant by the GData code.
And the request uri is: https://www.google.com/accounts/OAuthGetAccessToken
The error's happening at line 186 as per the class located here: http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/src/core/oauthutil.cs?r=1123
This may be completely unrelated but the URL you have specified in your scope
https://docs.google.com/calendar/feeds/
returns a 404 error
I think you should be using the following instead:
http://www.google.com/calendar/feeds/default/
or possibly http://www.google.com/calendar/feeds/default/owncalendars/full
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With