Mobile Payment SDK - failure to authorize

I’m using the sample code from Github for the Mobile Payment SDK. I’ve followed the instructions on the page and copied the three values into environments.xml, but I can’t get authorized. After the call to authorize(), the result is success, and the authorization state changed callback shows isAuthorized=true, but then immediately afterwards there is another call to the callback with isAuthorized=false (and it’s correct that the app is not authorized).

Any thoughts about what could be going wrong? I don’t see anywhere to find a reason for the 2nd callback (isAuthorized=false) or anywhere to get an error message (since the initial result is success).

I’m using the latest version of Android Studio, and the built-in emulator. My account is in Canada if that matters, but the documentation says Mobile Payment SDK is available for Canada, so I don’t think that’s the problem. I’m trying to use the sandbox.

1 Like

:waving_hand: 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:

Additional Documentation

Build on Android
Authorize the Mobile Payments SDK
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.

Your using your sandbox access token or sandbox OAuth access token when this happens? Also have you correctly added the app signature? :slight_smile:

Hi Bryan - thank you for your quick reply! Yes, I have copied:

  1. The Sandbox Application ID (from the Credentials page for my app in the developer console) to the mpsdk_application_id parameter in environments.xml.
  2. The Sandbox Access token (also from the Credentials page for my app in the developer console) to the mpsdk_access_token parameter in environments.xml.
  3. the Location ID (from the Locations page for my app in the developer console) to the mpsdk_location_id parameter in environments.xml.

Alas, I get the behavior as described. I also tried a “real” device (not the simulator), as well as an app I developed from scratch (not just the one from your github repo), and I get the same behavior.

I believe the 3 steps above are what are requested in the github documentation (GitHub - square/mobile-payments-sdk-android: Public repository that host the Square Mobile Payments SDK Android tech refs and example app.).

Should I be using sandbox OAuth instead?

Those are the correct credentials. Are you in developer mode? :slight_smile:

On my tablet? With the 7 presses on the Build Number? Yes.

Or are you referring to a different developer mode?

ETA: I disabled Android developer mode on my tablet, and I get the same bad/unfortunate behavior :frowning:

Small update. I disabled developer mode on my tablet, and installed the regular Square App. I was able to log in, connect to a physical reader, and take a credit card payment (in production).

But the test code/app from Github still doesn’t work on the same tablet.

So I’m not sure if the problem is with my account and/or the sandbox, or something specific to the Mobile Payments SDK?

We’ve identified an issue with the latest version of Mobile Payments SDK that doesn’t let it Authorize in sandbox. Production isn’t effected however sandbox currently won’t Authorize. I’ll be sure to reach out with any updates. :slight_smile:

1 Like

Thanks. That’s not the news I was hoping for, but at least it tells me that I’m (probably) not crazy. I’ll see what happens when I move my test app over to prod.

The issue has been resolved now and Authorize in sandbox is working as expected. :slight_smile:

1 Like

Thanks for letting me know. I’m (successfully!) off and running in production now.