App reviews, troubleshooting, and recommendations
I am developing a Shopify app using Shopify C# (ShopifySharp), and it is working fine in the test environment. However, when I try to push the app to production, I encounter the error: "Not authenticating with session tokens" in App Distribution.
I do not understand how to implement session tokens in my application or the necessary steps. I have already validated the JWT token and request, but the issue in App Admin Distribution remains unresolved.
Please help me. Thank you in advance.
my code is:
public ActionResult Install(string shop, string signature, string timestamp, string host, string session, string id_token) {
var _shopifyRequestValidationUtility = new ShopifyRequestValidationUtility();
if (!_shopifyRequestValidationUtility.IsAuthenticRequest(Request.QueryString.ToString(), _secretKey)) {
return new ContentResult() {
Content = "",
StatusCode = StatusCodes.Status401Unauthorized,
};
}
if (!CommonHelperServices.ValidateJWTToken(id_token, _secretKey)) {
return new ContentResult() {
Content = "",
StatusCode = StatusCodes.Status401Unauthorized,
};
}
string redirectUrl = _appUrl + "/auth";
var _store = storeServices.GetStore(shop.Trim());
var _shopifyOauthUtility = new ShopifyOauthUtility();
Uri authUrl = _shopifyOauthUtility.BuildAuthorizationUrl(new AuthorizationUrlOptions() {
ClientId = _apiKey,
RedirectUrl = redirectUrl,
Scopes = new List < string > () {
"read_products",
"write_products",
"unauthenticated_read_product_listings",
"read_product_listings",
"read_collection_listings",
"unauthenticated_read_collection_listings",
"write_content",
"write_price_rules",
"read_discounts",
"write_discounts",
"read_orders",
"read_themes"
},
ShopDomain = shop,
State = session
});
string _host = Encription.Base64DecodeCrypto(host + "=");
bool UrlRedirection = false;
if (_host.Contains("admin.shopify.com")) {
UrlRedirection = true;
}
if (_store.StoreId > 0 && _store.IsActive && UrlRedirection) {
var url = authUrl.ToString() + "&host=" + shop + "&forceRedirect=true";
url = authUrl.ToString().Replace(shop, "admin.shopify.com/store/" + _store.MyShopifyDomain.ToLower().Replace(".myshopify.com", ""));
return Redirect(url);
} else {
return Redirect(authUrl.ToString());
}
}
public async Task < ActionResult > Auth(string shop, string code) {
string redirectUrl = "";
AuthOutputModel model = new AuthOutputModel() {
Shop = Encription.Encrypt(shop)
};
string shopAccessToken = string.Empty;
try {
var _shopifyRequestValidationUtility = new ShopifyRequestValidationUtility();
if (_shopifyRequestValidationUtility.IsAuthenticRequest(Request.QueryString.ToString(), _secretKey)) {
model.IsValidData = true;
var _shopifyOauthUtility = new ShopifyOauthUtility();
var AuthorizeResult = await _shopifyOauthUtility.AuthorizeAsync(code, shop, _apiKey, _secretKey);
if (!string.IsNullOrEmpty(AuthorizeResult.AccessToken)) {
// app business code here
} else {
return new ContentResult() {
Content = "",
StatusCode = StatusCodes.Status401Unauthorized,
};
}
}
return new ContentResult() {
Content = "",
StatusCode = StatusCodes.Status401Unauthorized,
};
} catch (Exception ex) {
return new ContentResult() {
Content = "",
StatusCode = StatusCodes.Status401Unauthorized,
};
}
Did you manage to solve this?
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025