Skip to main content

I am trying to access contacts via the API using the ruby gem in a Ruby on Rails app. Have  a test workspace and have created an app in the developer portal in this workspace. Also generated an access token.

I am able to create a client object in the rails console.

However I get an authentication error when I try and make any calls to the api:

>1] pry(main)> intercom = Intercom::Client.new(token: ENVV'INTERCOM_TOKEN'], api_version: '2.9')
=> #<Intercom::Client:0x0000000130716a48
@api_version="2.9",
@base_url="https://api.intercom.io",
@handle_rate_limit=false,
@rate_limit_details={},
@timeouts={:open_timeout=>30, :read_timeout=>90},
@token="'***************************************">
>2] pry(main)> intercom.contacts.find(id: '56f0399fc1f09a1bf6000200')
Intercom::AuthenticationError: Unauthorized
from /Users/dsingh/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/intercom-4.2.1/lib/intercom/request.rb:164:in `raise_errors_on_failure'

Is there some other configuration needed for authentication.

 

(I am able to make calls successfully via the API Explorer by the way but want to do wholesale deletion of all users and import a fresh set so want to be able to loop through each contact)

Hey @Dev Singh Racheal from the support engineer team here👋 

 

I am seeing a invalid token error in our logs for this call:
E, d2023-05-17T19:42:33.322193 #678754] ERROR -- : 0011v9idqiq55iscjl4g] Invalid token returned from Eagle. error_response_body={"type":"error","status":401,"message":"Authentication Error"}

 

This can mean that your API Key is incorrect or that your app does not have permissions to make that API call. Could you double check in your Developer Hub that you are copying over the complete access token, and that your token has the correct permissions? If you need to edit your permissions, just a heads up that you will need to regenerate your token!
 


Reply