Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Drive: Error in retrieving access and refresh tokens
    text
    copied!<p>I am trying to access google drive from my app for WP7. But when i try to get access token in exchange for Authorization code, I get BAD REQUEST from server.</p> <p>My POST request as seen in Fidler:</p> <pre><code>POST https://accounts.google.com/o/oauth2/token HTTP/1.1 Accept: */* Referer: file:///Applications/Install/7128457C-3AF4-41C4-A606-742068B1463F/Install/ Content-Length: 240 Accept-Encoding: identity Content-Type: application/x-www-form-urlencoded User-Agent: NativeHost Host: accounts.google.com Connection: Keep-Alive Cache-Control: no-cache code=&lt;*Authorization_Code*&gt;&amp; client_id=&lt;*My_Client_Id*&gt;&amp; client_secret=&lt;*My_Client_Secret*&gt;&amp; redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&amp; grant_type=authorization_code </code></pre> <p>Response from server:</p> <pre><code>HTTP/1.1 400 Bad Request Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: Fri, 01 Jan 1990 00:00:00 GMT Date: Sat, 07 Sep 2013 14:05:35 GMT Content-Type: application/json X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Alternate-Protocol: 443:quic Transfer-Encoding: chunked 21 { "error" : "invalid_request" } 0 </code></pre> <p>My Code:</p> <pre><code>StringBuilder postData = new StringBuilder(); postData.AppendFormat("{0}={1}", "code", HttpUtility.UrlEncode(AuthorizationCode)); postData.AppendFormat("&amp;\n{0}={1}", "client_id", HttpUtility.UrlEncode(ClientId)); postData.AppendFormat("&amp;\n{0}={1}", "client_secret", HttpUtility.UrlEncode(ClientSecret)); postData.AppendFormat("&amp;\n{0}={1}", "redirect_uri", HttpUtility.UrlEncode("urn:ietf:wg:oauth:2.0:oob")); postData.AppendFormat("&amp;\n{0}={1}", "grant_type", HttpUtility.UrlEncode("authorization_code")); WebClient client = new WebClient(); client.UploadStringCompleted += TokenResponse; client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; client.UploadStringAsync(new Uri("https://accounts.google.com/o/oauth2/token",UriKind.Absolute), "POST", postData.ToString()); </code></pre> <p>I get this result both on emulator as well as Lumia 820. I also tried without using HttpUtility in POST request but didn't work. Any help?</p>
 

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