mobile-buy-sdk-android失败,出现错误com.shopify.buy3.GraphHttpError

沉舟侧畔千帆进,病树前头万木春。这篇文章主要讲述mobile-buy-sdk-android失败,出现错误com.shopify.buy3.GraphHttpError相关的知识,希望能为你提供帮助。
【mobile-buy-sdk-android失败,出现错误com.shopify.buy3.GraphHttpError】下面是代码和错误消息
错误信息:
“错误com.shopify.buy3.GraphHttpError:HTTP 403 Forbidden”
403错误表示我没有正确验证请求,我在这里做错了什么?代码

OkHttpClient httpClient = new OkHttpClient.Builder() .addNetworkInterceptor(new HttpLoggingInterceptor()) .build(); GraphClient gl =GraphClient.builder(this) .shopDomain("< shop name> .myshopify.com") .accessToken("myAPIKey") .httpClient(httpClient) .httpCache(new File(getApplicationContext().getCacheDir(), "/http"), 10 * 1024 * 1024) .defaultHttpCachePolicy(HttpCachePolicy.CACHE_FIRST.expireAfter(5, TimeUnit.MINUTES)) // cached response valid by default for 5 minutes .build(); Storefront.QueryRootQuery query = Storefront.query(new Storefront.QueryRootQueryDefinition() { @Override public void define(final Storefront.QueryRootQuery rootQueryBuilder) { rootQueryBuilder.shop(new Storefront.ShopQueryDefinition() { @Override public void define(final Storefront.ShopQuery shopQueryBuilder) { shopQueryBuilder.privacyPolicy(new Storefront.ShopPolicyQueryDefinition() { @Override public void define(final Storefront.ShopPolicyQuery policyQueryBuilder) { policyQueryBuilder.body(); policyQueryBuilder.url(); policyQueryBuilder.title(); } }); } }); } }); QueryGraphCall call = cl.queryGraph(query); call.enqueue(new GraphCall.Callback< Storefront.QueryRoot> () { @Override public void onResponse(@NonNull GraphResponse< Storefront.QueryRoot> response) { String body = response.data().getShop().getPrivacyPolicy().getBody(); Log.v(TAG,"boby : " + body); }@Override public void onFailure(@NonNull GraphError error) { Log.v(TAG,"error " + error.toString()); } });

答案
HTTP 403禁止
阅读Private authentication
在您对Shopify的私人应用程序进行身份验证之前,您需要从要与应用程序连接的商店的Shopify管理员生成所需的凭据。
如果要使用Storefront API,请选择“允许此应用程序使用Storefront API访问店面数据”。这将生成Storefront访问令牌。

    推荐阅读