Request a Mobile Authorization Code on the Command Line

Request authorization tokens with a command-line tool to initialize Square mobile solutions like the Reader SDK.

To use the steps in this topic, you need the following:

  • An active location ID - Copy a valid developer account location ID from the Production mode Locations settings page of your Square application in the Developer Dashboard.
  • A valid access token - For more information, see Access Tokens and Other Square Credentials.
Link to section

Generate a mobile authorization code

You should generate mobile authorization codes programmatically because they're short lived and cannot be hardcoded or reused. You might, however, need to generate a mobile authorization code manually during development.

To manually generate a mobile authorization code:

  1. Open the Developer Dashboard.
  2. In the left pane, choose Credentials, and then copy your personal access token from the Credentials page.
  3. In the left pane, choose Locations, and then copy an active location ID from the Locations page.
  1. Paste the values into the following cURL command:

    curl https://connect.squareup.com/mobile/authorization-code \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN' \ -d '{"location_id":"YOUR_LOCATION_ID"}'

    You should get a response that looks like this:

    squareup.com/mobile/authorization-code { "authorization_code": "YOUR_MOBILE_AUTHORIZATION_CODE", "expires_at": "2018-05-11T02:05:07Z" }
Link to section

See also