c# 4.0 - Authentication for Box in C# 4.0 -


I am trying to use token using the code below in the C # language, but I have 400 bad requests exception Are getting .

Code: WebRequest httpWReq = WebRequest.Create ("https://www.box.com/api/oauth2/token"); String postData = "grant_type = authorization_code"; PostData + "" & amp; Code = "+ code; postdata +" "& amp; customer_id = MY_CLIENT_ID"; PostData + "& amp; client_secret = MY_CLIENT_SECRET"; PostData + "" & amp; Redirect_uri = https: //www.google.com "; byte [] data = encoding. UTF8.GetBytes (PostData); HttpWReq.Method =" POST "; HttpWReq.ContentType =" application / x-www-form-urlencoding " ;); Stream.Write (data, 0, data. Lang);} Var response = httpWReq.GetResponse (); Var responseflow = response using the HttpWReq.ContentLength = data.Length; (stream stream = httpWReq.GetRequestStream ()) Gaterespanstream (); (Var Reader = Using new streamminder (responses) {var responseReader = reader.ReadToEnd (); MessageBox.Show (responseReader);}

But always the following Tru : "Invalid": "invalid_request", "error_description": "missing invalid grant_type parameter or parameter"}

This problem How to remove?

Any help would be appreciated thanks in advance.

Thanks, Harish Reddy

I see two possible problems, both with this line:

  postData + = "& redirect_uri = https: // www .google.com ";   
  1. I think you'll need a redirect URI urlencode.
  2. I assume that you do not own the domain google.com , so this is an invalid value. :) You will need to tell back to the domain that you are requesting. Or better yet, preset this redirect url on the configuration page of your box app. By chance, you (and related) are on GitHub and NuGet, (full disclosure: I contribute to both.)

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -