google-api-client gem を使用してGoogle Search API for Shoppingにアクセスしようとしています。残念ながら、 Google APIs Consoleで access_token を作成しても認証できないようです。
これが私のコードです:
client = Google::APIClient.new
client.authorization.access_token = "<MY_CONSOLE_ACCESS_TOKEN>"
client.authorization.scope = "https://www.googleapis.com/auth/shoppingapi"
shopping = client.discovered_api("shopping", "v1")
response = client.execute(api_method: shopping.products.list,
parameters: { source: "public" })
を表示response.data
すると、エラー メッセージが表示されます。
#<Google::APIClient::Schema::Shopping::V1::Products:0x809d6e14 DATA:{"error"=>{"errors"=>[{"domain"=>"global", "reason"=>"authError", "message"=>"Invalid Credentials", "locationType"=>"header", "location"=>"Authorization"}], "code"=>401, "message"=>"Invalid Credentials"}}>
私は何を間違っていますか?