Hi Xuan,
You mentioned that you have that code running in your Omniauth callback controller. Does this mean you are using an OAuth2 strategy within Omniauth (such as
https://github.com/intridea/omniauth-oauth2 or something that builds on it)?
If you are doing that, Omniauth already does the auth_code to access_token exchange for you, as you can see on
https://github.com/intridea/omniauth-oauth2/blob/master/lib/omniauth/strategies/oauth2.rb#L75 which calls
https://github.com/intridea/omniauth-oauth2/blob/master/lib/omniauth/strategies/oauth2.rb#L91-L94
Therefore, Omniauth uses up your auth_code before you make your curl request, which is why you are getting the error you mentioned.
If you are doing this in Ruby, I strongly suggest against parsing JSON that you get by running curl in a separate process (like in your code example), and instead recommend using an OAuth2 library, as shown on
https://stripe.com/docs/connect/oauth#sample-code. Alternatively, you can use Omniauth with an OAuth2 based strategy, depending on which of these better suits your workflow.
Hope this helps!
Cheers,
Vlad