Bigcommerce验证code [英] Bigcommerce Authentication code

查看:162
本文介绍了Bigcommerce验证code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得认证code?

How to get Authentication code ?

我使用 https://login.bigcommerce.com/oauth2 的网址,并通过CLIENT_ID = { 0}&放大器; redirect_uri = {1}&安培; RESPONSE_TYPE = code {2} {3} get方法,但它给我的错误你要找的人是不存在的页面。

I am using https://login.bigcommerce.com/oauth2 url and passing client_id={0}&redirect_uri={1}&response_type=code{2}{3} in get method, but it gives me error "The page you were looking for doesn't exist."

我知道得到验证code后,我可以生成令牌。但是,第一个步骤是没有tclear如何通过登录页面获取验证code?

I know after getting Authentication code I can generate token. But first step is no tclear how to get Authentication code using login page?

推荐答案

我刚刚经历了这个OAuth的令牌问题和文档都没有太大的帮助,但一旦我去我终于通过创建来获取应用程序的设置我的SSL回调本地页我的服务器上。有一次,我指定的URL中的应用程序设置我是所有设置。需要说明的是,我不得不做执行从服务器本身,因为它不是一个公共URL安装在登录到卑诗省的店老板。当时我能从查询字符串获得临时令牌,回发到 https://login.bigcommerce.com / oauth2 /令牌并获得响应流永久标记。

I just went through this oauth token issue and the docs haven't been much help, but once I got going I finally managed to get the app setup by creating my SSL callback page locally on my server. Once I specified that URL in the app settings I was all set. The caveat being I had to do perform the 'install' from the server itself since it wasn't a public URL while logged into BC as the store owner. I was then able to get the temporary token from the querystring and post back to https://login.bigcommerce.com/oauth2/token and obtain the permanent token from the response stream.

您必须包括你的客户ID,客户端秘密和的Request.QueryString [code]值在帖子的请求。

You have to include your client id, client secret and the request.querystring["code"] value in your post request.

下面是我如何获得永久标记,这将是内部jsonResponse:

Here's how I obtained the permanent token which will be inside 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();

这篇关于Bigcommerce验证code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆