Missing 'client_id' with latest Ruby SDK

Hi,

I’m using (I believe) everything correctly with the latest Ruby SDK, but I’m getting the notorious “missing required parameter ‘client_id’” error when trying to obtain the token.

App ID: sandbox-sq0idb-yxibw1qw1_oQQg8RxBw6Mw

Code:

client = Square::Client.new(
  base_url: "https://connect.squareupsandbox.com" # Square::Environment::SANDBOX
)  # I tried specifying the URL directly

    # Provide the code in a request to the Obtain Token endpoint
    oauth_request_body = {
      'client_id ' => application_id,
      'client_secret' => application_secret,
      'code' => authorization_code,
      'grant_type' => 'authorization_code'
    }

    response = oauth_api.obtain_token(**oauth_request_body)

Log line:

2025-09-06 10:10:13 - RuntimeError - {
  "message": "missing required parameter 'client_id'",
  "type": "bad_request.missing_parameter"
}
:
	/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/square.rb-44.0.0.20250820/lib/square/o_auth/client.rb:77:in `obtain_token'

If I take the code and use the API Explorer, I can obtain the token no problem, so I assume something is wrong in my configuration, but no idea what :expressionless:

Thanks in advance!

OK, I eventually realised there was a space 'client_id ’ => application_id :man_facepalming:

However, now I’m getting the following

undefined method `success?' for an instance of Square::Types::ObtainTokenResponse

I expect this is just because I started with a version of the Ruby OAuth flow and the library has changed from that sample code.

Thanks for sharing your findings. Are you getting back the access token and refresh token? :slight_smile:

I am, yes, thanks for checking in!