请在获取代码后获取accessstoken请求通过C#中的以下代码获取访问权限但是它总是返回我远程服务(400)错误请求
curl https://www.box.com/api/oauth2/token \
-d 'grant_type=authorization_code&code={your_code}&client_id={your_client_id}&client_secret={your_client_secret}' \
-X POST
以下是我正在使用的代码:
Stream stream = null;
WebRequest webRequest = null;
StreamReader streamReader = null;
WebResponse webResponse = null;
webRequest = WebRequest.Create("box.com/api/oauth2/token");
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
byte[] data = Encoding.GetEncoding("UTF-8").GetBytes("'grant_type=authorization_code&code={myc??ode}&client_id={myclient_id}&client_secret={myclient_secret}'");
webRequest.ContentLength = data.Length;
Stream reqstr = webRequest.GetRequestStream();
reqstr.Write(data, 0, data.Length);
reqstr.Close();
webResponse = webRequest.GetResponse();
stream = webResponse.GetResponseStream();
streamReader = new StreamReader(stream);
WebResponseData = streamReader.ReadToEnd();