我使用https://github.com/nozzlegear/ShopifySharp .Net库来使用Shopify Api。我刚刚创建了dev webshop,我想测试一些GET方法。在文档中我看到了下面的代码:
string code = Request.QueryString["code"];
string myShopifyUrl = Request.QueryString["shop"];
string accessToken = await AuthorizationService.Authorize(code, myShopifyUrl, shopifyApiKey, shopifySecretKey); 我理解的所有参数,除了第一,这是什么代码,我应该从哪里获得它??谢谢
发布于 2018-03-28 13:25:39
发布于 2018-03-28 13:23:50
您应该在您的控制器中创建一个方法,它将接收来自Shopify的回调:
public ActionResult Callback(string code, string shop) {
string accessToken = await AuthorizationService.Authorize(code, myShopifyUrl, shopifyApiKey, shopifySecretKey);
}然后在构建授权URL时,您应该将变量redirectUrl设置为上面的方法:
//This is the user's store URL.
string usersMyShopifyUrl = "https://example.myshopify.com";
// A URL to redirect the user to after they've confirmed app installation.
// This URL is required, and must be listed in your app's settings in your Shopify app dashboard.
// It's case-sensitive too!
string redirectUrl = "https://example.com/my/redirect/url";
//An array of the Shopify access scopes your application needs to run.
var scopes = new List<AuthorizationScope>()
{
AuthorizationScope.ReadCustomers,
AuthorizationScope.WriteCustomers
};
//Or, use an array of string permissions
var scopes = new List<string>()
{
"read_customers",
"write_customers"
}
//All AuthorizationService methods are static.
string authUrl = AuthorizationService.BuildAuthorizationUrl(scopes, usersMyShopifyUrl, shopifyApiKey, redirectUrl);一旦用户将被重定向到授权URL,它将打开购物页面,用户将能够安装应用程序。然后,Shopify会使用code和shop参数将他重定向到您的回调方法
https://stackoverflow.com/questions/49517603
复制相似问题