begin
nylas = Nylas::API.new(
app_id: "CLIENT_ID",
app_secret: "CLIENT_SECRET",
access_token: "ACCESS_TOKEN"
)
nylas.exchange_code_for_token("abc")
rescue => e
p e
p e.message # This should contain valid info and not just 'message'
end
Output:
#<Nylas::InvalidRequest: message>
"message"
Describe the bug Nylas API seems to return a html response for error cases unless 'Accept: application/json' is explicitly specified https://developer.nylas.com/docs/api/#post/oauth/token
This leads to invalid exception messages as this gem is expecting a json response back.
I do not see 'Accept: application/json' in default_headers in https://github.com/nylas/nylas-ruby/blob/main/lib/nylas/http_client.rb#L180-L186 Either setting this within gem or returning a default application/json in case content-type: application/json from nylas api should fix this.
To Reproduce Ruby Code
Curl with Accept: application/json
Curl without Accept: application/json
Expected behavior Exceptions should contain correct information and messages so calling clients can appropriately classify / take decisions https://github.com/nylas/nylas-ruby/blob/ef90d46f92d3e4467b991d7fb74156194c5186a7/lib/nylas/errors.rb#L49-L55
SDK Version: nylas (5.14.0)
Additional context Add any other context about the problem here.