Oauth flow in sandox is not working

Hello,

I am using the code example from Square Connect API OAuth Ruby Example, but I am encountering an issue. The page returns a 400 Bad Request error, and the screen is empty

The URL I used is:
https://squareupsandbox.com/oauth2/authorize?client_id=sandbox-sq0idb-c4UHQJ4HVi2OnAyxKJMfzA

I’ve tried it in the past and it worked without any issue.
Could you please help me identify what I might be missing or misconfiguring?

Thank you.

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

https://developer.squareup.com/docs/oauth-api/walkthrough2

Additional Documentation

OAuth Walkthrough: Test Authorization with Web Server
OAuth Walkthrough: Test Authorization with Web Server
Build with the Mobile Authorization API

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Is the example configured correctly? Did you by chance configure an access token as the client secret? :slightly_smiling_face:

Yep. I’ve updated the application_id and application_secret in the code. Just to confirm, we don’t need the application_secret for generating the Connect URL, correct?

get '/' do
  url = "#{connect_host}/oauth2/authorize?client_id=#{application_id}"
  content = "
  <link type='text/css' rel='stylesheet' href='style.css'>
  <meta name='viewport' content='width=device-width'>
  <div class='wrapper'>
    <a class='btn'
     href='#{url}'>
       <strong>Authorize</strong>
    </a>
  </div>"
  erb :base, :locals => {:content => content}
end

When I set the connection_host to https://connect.squareup.com, it’s redirecting properly. The issue is with sandbox - https://connect.squareupsandbox.com.

Do you have the sandbox Seller Dashboard open in a different tab? If you don’t can you try it with the the Dashboard open on another tab? :slightly_smiling_face:

Hello thanks for the input!
It’s working now. It would be more intuitive if the page actually shows some error instead of a blank page.

Thanks!

We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. :slightly_smiling_face: