Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google play integrity api issue

I am migrating my app from Google play safety net api to Integrity api, but getting below error from api-

com.google.android.play.core.integrity.IntegrityServiceException: -12: Integrity API error (-12): Unknown internal Google server error. Retry with an exponential backoff. Consider filing a bug if fails consistently (https://developer.android.com/reference/com/google/android/play/core/integrity/model/IntegrityErrorCode.html#GOOGLE_SERVER_UNAVAILABLE).

Below is my code sample-

String str = "MTY1Mzk3NTAxMjYwNjE2NTM5NzUwMTI2MDc=";
byte[] strBytes = android.util.Base64.decode(str, android.util.Base64.DEFAULT);
byte[] encoded = android.util.Base64.encode(
            strBytes, android.util.Base64.URL_SAFE | android.util.Base64.NO_PADDING | android.util.Base64.NO_WRAP);
String nonce =  new String(encoded);
IntegrityManager integrityManager = 
                 IntegrityManagerFactory.create(getApplicationContext());
Task<IntegrityTokenResponse> integrityTokenResponse =
            integrityManager
                    .requestIntegrityToken(
                            IntegrityTokenRequest.builder().setNonce(nonce).build());

    integrityTokenResponse.addOnCompleteListener(new OnCompleteListener<IntegrityTokenResponse>() {
        @Override
        public void onComplete(@NonNull Task<IntegrityTokenResponse> task) {}
    });

    integrityTokenResponse.addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {}
    });

Any help will be appreciated.Thank you.

like image 450
sanil Avatar asked Oct 24 '25 19:10

sanil


2 Answers

I've seen that problem, and for me the solution was to include the Cloud project number into the integrity request:

IntegrityTokenRequest.builder()
            .setCloudProjectNumber([YOUR_CLOUD_PROJECT_NUMBER])
            .setNonce(nonce)
            .build()

I build an SDK, so that's the only solution available, however there is an alternative, if you have an app distributed through the Play Store:

In the Play Console, navigate to the Release section of the left menu. Go to Setup > App integrity. Select the Integrity API tab to get started.

like image 70
abel Avatar answered Oct 27 '25 10:10

abel


I am also migrating for safetynet check. Implemented as above bit recieving exception as below W/System.err: com.google.android.play.core.integrity.IntegrityServiceException: -8: Integrity API error (-8): The calling app is making too many requests to the API and hence is throttled. W/System.err: Retry with an exponential backoff. W/System.err: (https://developer.android.com/reference/com/google/android/play/core/integrity/model/IntegrityErrorCode.html#TOO_MANY_REQUESTS). W/System.err: at com.google.android.play.core.integrity.zzs.zzb(com.google.android.play:integrity@@1.0.0:5) W/System.err: at com.google.android.play.integrity.internal.zzg.zza(com.google.android.play:integrity@@1.0.0:2) W/System.err: at com.google.android.play.integrity.internal.zzb.onTransact(com.google.android.play:integrity@@1.0.0:3) W/System.err: at android.os.Binder.execTransactInternal(Binder.java:1187) W/System.err: at android.os.Binder.execTransact(Binder.java:1146)

like image 28
anithaa Avatar answered Oct 27 '25 10:10

anithaa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!