Hello! I can't seem to figure out why I'm not getting authenticated for search results. This is my Ruby script.
site_path = 'https://api.sandbox.ebay.com/identity/v1/oauth2/token' auth_body = "grant_type=client_credentials&scope=#{URI.encode_www_form_component('https://api.ebay.com/oauth/api_scope')}" auth_client_secret = "#{ENV['EBAY_CLIENT_ID']}:#{ENV['EBAY_CLIENT_SECRET']}" auth_request = Typhoeus::Request.new( site_path, method: :post, body: auth_body, headers: {'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => "Basic #{Base64.urlsafe_encode64(auth_client_secret)}" } ) auth_response = auth_request.run access_token = JSON.parse(auth_response.body)['access_token'] request = Typhoeus::Request.new('https://api.ebay.com/buy/browse/v1/item_summary/search?q=drone&limit=3', method: :get, headers: {'Authorization' => "Bearer #{access_token}" }) response = request.run puts "|=== #{response.code} =======================" puts response.body
and this is the response I'm getting:
|=== 401 ======================= { "errors" : [ { "errorId" : 1001, "domain" : "OAuth", "category" : "REQUEST", "message" : "Invalid access token", "longMessage" : "Invalid access token. Check the value of the Authorization HTTP request header." } ] }
When I check the access_token variable it appears to be a valid token. Does it need to be encoded in any way?
Thanks in advance.