Mobile Payments SDK save authorization

Hello,

For Reader SDK once initialized and authorized, the SDK stores authorization, and when a user opens the app next time no authorization is needed. We can use [SQRDReaderSDK sharedSDK].isAuthorized to confirm.

Is there anything similar available in SQMPMobilePaymentsSDK? It seems every time the app opens it requires authorization before using the SDK.

: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 with the Mobile Authorization API
Reader SDK Requirements
Reader SDK

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.

You can check whether a user of your application is authorized, notAuthorized, or (in the process of) authorizing by checking AuthorizationManager.state prior to beginning authorization.

To track changes in the authorization state, add an AuthorizationStateObserver to your viewController to receive updates to the authorization state whenever the Mobile Payments SDK is authorized or deauthorized. :slight_smile:

Hi Bryan,

I am checking like below:

- (BOOL)isSquareSDKAuthorized
{
    if (_isInitialized)
    {
        if (SQMPMobilePaymentsSDK.shared.authorizationManager.state == SQMPAuthorizationStateAuthorized)
            return YES;
        else
            return NO;
    }
    return NO;
}

It returns always false because the SDK is not authorized because I am authorizing the SDK later in the app. But previously I had authorized the SDK and I am just opening the app again.

So is there a way that SDK remembers that it was authorized previously like [SQRDReaderSDK sharedSDK].isAuthorized? Otherwise, I need to call APIs to get access tokens every time I open the app. My app just checks authorization at start-up to display the Location name on the screen.

Is it possible?

Access tokens are good for 30 day’s and we recommend refreshing them every 7 days. You can use the same access token over and over agian to call the authorize() method with an OAuth access token and location ID. :slight_smile:

Hi Bryan,

Ok understood. Thanks for the info.

Tokens are good for 30 day’s

This applies to the below token, right?

No, that token will never expire. Only OAuth tokens expire. :slight_smile: