I randomly started getting this error recently and haven’t been able to figure out why:
ShopifyAPI::Errors::HttpResponseError ({
"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)",
"error_reference":"If you report this error, please include this id: **2bcd0c9f-6c34-49c5-b2a3-05c448f6aa74-1738459181**."
})
My app is a Try Before You Buy app, it uses the 2024-01 API and all keys, secrets and scopes are correct after double checking them. There have been no major changes to the app recently.
Some extra logs that should help pinpoint what is causing the error:
The actual code that is triggering the error:
graphql_order = FetchOrder.call(id: @order.shopify_id)
# frozen_string_literal: true
class FetchOrder < ApplicationService
attr_accessor :error
FETCH_ORDER_QUERY = <<~QUERY
query fetchOrder($id: ID!, $after: String) {
order(id: $id) {
id
createdAt
updatedAt
closedAt
cancelledAt
clientIp
name
displayFinancialStatus
displayFulfillmentStatus
customer {
email
}
note
tags
fullyPaid
totalOutstandingSet {
shopMoney {
amount
}
}
paymentTerms {
id
paymentSchedules(first: 1) {
edges {
node {
dueAt
}
}
}
}
paymentCollectionDetails {
vaultedPaymentMethods {
id
}
}
lineItems(first: 10, after: $after) {
edges {
node {
id
image {
url
}
quantity
restockable
unfulfilledQuantity
title
variantTitle
sellingPlan {
sellingPlanId
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
totalPriceSet {
shopMoney {
amount
}
}
}
}
QUERY
def initialize(id:, after: nil)
super()
@Id = id
@after = after
@session = ShopifyAPI::Context.active_session
@Client = ShopifyAPI::Clients::Graphql::Admin.new(session: @session)
end
def call
variables = {
id: @Id,
after: @after
}
response = @Client.query(query: FETCH_ORDER_QUERY, variables:)
unless response.body["errors"].nil?
raise response.body.dig("errors", 0, "message") and return
end
response
rescue ActiveRecord::RecordInvalid, StandardError => e
Rails.logger.error("[FetchOrder Failed]: #{e.message}")
@error = e.message
raise e
end
end