如何获取验证码?
我正在使用get url并在https://login.bigcommerce.com/oauth2方法中传递client_id={0}&redirect_uri={1}&response_type=code{2}{3},但它给出错误“您正在寻找的页面不存在”。
我知道在获得验证码后,我可以生成令牌。但是第一步是不清楚如何使用登录页面获取验证码?
发布于 2014-06-17 04:08:55
我刚刚经历了这个oauth令牌问题,文档并没有太多帮助,但一旦我开始,我终于设法通过在我的服务器上本地创建我的SSL回调页面来安装应用程序。一旦我在应用程序设置中指定了该URL,我就完成了所有设置。需要注意的是,我必须从服务器本身执行“install”,因为在以商店所有者身份登录BC时,它不是一个公共URL。然后,我可以从查询字符串中获取临时令牌,并将其发送回https://login.bigcommerce.com/oauth2/token,然后从响应流中获取永久令牌。
你必须在你的post请求中包含你的客户端id,客户端密码和request.querystring"code“值。
下面是我如何获得永久令牌的,该令牌将位于jsonResponse中:
string baseURL = "https://login.bigcommerce.com/oauth2/token";
string contentType = "application/x-www-form-urlencoded";
string callbackURL = <your SSL callback URL>
HttpWebRequest req = WebRequest.CreateHttp(baseURL);
req.AllowAutoRedirect = true;
req.ContentType = contentType;
req.Method = "POST";
//Build POST content body
StringBuilder sb = new StringBuilder();
sb.AppendFormat("client_id={0}", clientID);
sb.AppendFormat("&client_secret={0}", clientSecret);
sb.AppendFormat("&code={0}", tempToken);
sb.AppendFormat("&scope={0}", scopes);
sb.AppendFormat("&grant_type=authorization_code");
sb.AppendFormat("&redirect_uri={0}", callbackURL);
sb.AppendFormat("&context={0}", storeContext);
//Convert the content to byte array and set content length
string contentString = sb.ToString();
byte[] postData = Encoding.UTF8.GetBytes(contentString);
req.ContentLength = postData.Length;
//Send the data to login server
using (Stream stream = req.GetRequestStream())
{
stream.Write(postData, 0, postData.Length);
stream.Flush();
stream.Close();
}
//Get the request response object
WebResponse resp = req.GetResponse();
//Read the contents of the response
StreamReader sr = new StreamReader(resp.GetResponseStream());
string jsonResponse = sr.ReadToEnd();发布于 2014-11-18 04:13:14
如果您使用的方法与上面所示的方法类似,那么通过读取request.querystring“page_load”的值,在回调URL中定义的aspx页面的代码事件期间捕获临时令牌。您可以在商店的控制面板中找到您的商店哈希,如果我没记错的话,其中一个位置是旧的API帐户。HTH。
https://stackoverflow.com/questions/23897730
复制相似问题