Note that there are some explanatory texts on larger screens.

plurals
  1. POGet Access Token from Goodreads in Windows 8 apps
    primarykey
    data
    text
    <p>I'm developing a windows 8 app for goodreads (<a href="http://www.goodreads.com" rel="nofollow">http://www.goodreads.com</a>). I'm following the web authentication broker sample at <a href="http://code.msdn.microsoft.com/windowsapps/Web-Authentication-d0485122/view/Discussions" rel="nofollow">http://code.msdn.microsoft.com/windowsapps/Web-Authentication-d0485122/view/Discussions</a>. I managed to get the oauth token and the oauth token secret successfully. </p> <p>But I'm unable to send it back and get the access token from goodreads. I'm trying to send the constructed URL using the acquired oauth token and token sectret as mentioned in the code below. I'm trying to get the <strong>access token</strong> using the <strong>oauth token</strong> I received from Goodreads API using OAuth.</p> <p>In the given code "GetResponse2" variable is always set to null from the asynchronous data send method. I think it is because of the construction of the URL but I cannot figure out where it went wrong in the URL. Hope someone can help me.</p> <pre><code> if (oauth_token != null) { GoodreadsUrl = "https://www.goodreads.com/oauth/authorize?oauth_token=" + oauth_token; System.Uri StartUri = new Uri(GoodreadsUrl); System.Uri EndUri = new Uri(GoodreadsCallbackUrl); WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync( WebAuthenticationOptions.None, StartUri,EndUri); var response = WebAuthenticationResult.ResponseData; if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) { TimeSpan SinceEpoch2 = DateTime.UtcNow - new DateTime(1970, 1, 1); Random Rand2 = new Random(); GoodreadsUrl = "http://www.goodreads.com/oauth/access_token"; Int32 Nonce2 = Rand2.Next(1000000000); // // Compute base signature string and sign it. // This is a common operation that is required for all requests even after the token is obtained. // Parameters need to be sorted in alphabetical order // Keys and values should be URL Encoded. // String SigBaseStringParams2 = "oauth_callback=" + Uri.EscapeDataString(GoodreadsCallbackUrl); SigBaseStringParams2 += "&amp;" + "oauth_consumer_key=" + GoodreadsClientId; SigBaseStringParams2 += "&amp;" + "oauth_token=" + oauth_token; SigBaseStringParams2 += "&amp;" + "oauth_verifier=" + oauth_token_secret; SigBaseStringParams2 += "&amp;" + "oauth_nonce=" + Nonce2.ToString(); SigBaseStringParams2 += "&amp;" + "oauth_signature_method=HMAC-SHA1"; SigBaseStringParams2 += "&amp;" + "oauth_timestamp=" + Math.Round(SinceEpoch2.TotalSeconds); SigBaseStringParams2 += "&amp;" + "oauth_version=1.0"; String SigBaseString2 = "GET&amp;"; SigBaseString2 += Uri.EscapeDataString(GoodreadsUrl) + "&amp;" + Uri.EscapeDataString(SigBaseStringParams2); IBuffer KeyMaterial2 = CryptographicBuffer.ConvertStringToBinary(GoodreadsClientSecret + "&amp;", BinaryStringEncoding.Utf8); MacAlgorithmProvider HmacSha1Provider2 = MacAlgorithmProvider.OpenAlgorithm("HMAC_SHA1"); CryptographicKey MacKey2 = HmacSha1Provider2.CreateKey(KeyMaterial2); IBuffer DataToBeSigned2 = CryptographicBuffer.ConvertStringToBinary(SigBaseString2, BinaryStringEncoding.Utf8); IBuffer SignatureBuffer2 = CryptographicEngine.Sign(MacKey2, DataToBeSigned2); String Signature2 = CryptographicBuffer.EncodeToBase64String(SignatureBuffer2); String DataToPost2 = "OAuth oauth_callback=\"" + Uri.EscapeDataString(GoodreadsCallbackUrl) + "\", oauth_consumer_key=\"" + GoodreadsClientId + "\", oauth_nonce=\"" + Nonce2.ToString() + "\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"" + Math.Round(SinceEpoch2.TotalSeconds) + "\", oauth_version=\"1.0\", oauth_signature=\"" + Uri.EscapeDataString(Signature2) + "\""; GoodreadsUrl += "?" + SigBaseStringParams2 + "&amp;oauth_signature=" + Uri.EscapeDataString(Signature2); String GetResponse2 = await SendDataAsync(GoodreadsUrl); // DebugPrint("Received Data: " + GetResponse); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload