0

I have updated my rails version to 7, here when I try to get parsed from the oauth response it always returns an empty string, but not the parsed response, but in rails 4 it gave the parsed response.

For example:

in Rails 4

when I print oauth_response1

oauth_response1
#=> #<OAuth2::Response:0x007f65819254d0 @response=#<Faraday::Response:0x007f65913e0370 @env=#<Faraday::Env @method=:post @body="{\"success\":false,\"c_id\":\"343\",\"message\":\"success\"}" @response_headers={"Content-Type"=>"application/json"} @status=200>, @on_complete_callbacks=[]>, @options={:parse=>:automatic}>`

when I used parsed over this, which returns

oauth_response1.parsed
{"success"=>false, "c_id"=>"343", "message"=>"success"}

Similarly the same code in rails 7: when I print oauth_response1

oauth_response1

#<OAuth2::Response:0x00007fa4864912b8 @response=#<Faraday::Response:0x00007fa485ede1e0 @env=#<Faraday::Env @method=:post @request_body="{\"success\":false,\"c_id\":\"343\",\"message\":\"success\"}" @response_headers={"Content-Type"=>"application/json"} @status=200>, @on_complete_callbacks=[]>, @options={:parse=>:automatic}>

and when I give .parsed to this response, it returns an empty string as

oauth_response1.parsed

""

I have been debugging for the same, but can't find the root cause for the same, is there any way to approach this or fix the issue?? and how do the parsed will work?

engineersmnky
  • 25,495
  • 2
  • 36
  • 52
jansha
  • 164
  • 1
  • 8
  • 1
    Not sure what version of `OAuth2` you are using in each. Rails 4 to Rails 7 is a huge jump. Can you please provide additional details? – engineersmnky Feb 23 '23 at 16:24
  • Agree, maybe try to upgrade the version slowly then you can pinpoint when did the behavior break. There is a possibility that you updated the OAuth2 gem and it just gives different #toString method. – Patrick Feb 23 '23 at 17:29

0 Answers0