You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* A simple proof-of-concept to prepare for authorization and authorization
704
-
* token refresh with the Salesforce Mobile App Attestation Challenge API
705
-
* and Google Play Integrity API enabled.
706
-
*
707
-
* TODO: This will need to be made production-ready in the future. ECJ20260312
708
-
// TODO: Discuss a suitable scope for this as attaching it to this singleton may further legacy patterns. ECJ20260312
688
+
* Creates a client for use with the Salesforce App Attestation External
689
+
* Client App (ECA) Plugin
690
+
* @return The app authentication attestation client
709
691
*/
710
-
funtestGooglePlayIntegrityApiPreparation() {
711
-
CoroutineScope(Default).launch {
712
-
// The app's corresponding Cloud Project Number.
713
-
// TODO: Determine where this value would be provided to or by Salesforce Mobile SDK. ECJ20260311
714
-
val cloudProjectNumber =-1L// TODO: Google Cloud Project Number. ECJ20260311
715
-
716
-
// TODO: For production, determine where Salesforce Mobile SDK should encapsulate the logic of preparing the Google Play Integrity Manager and Token Provider. That can likely be a single method which encapsulates storing the token for later use in authorization plus refreshing the Token Provider when needed. ECJ20260311
717
-
718
-
// Create the Google Play Integrity Manager and Token Provider.
719
-
val integrityManager = createStandard(this@SalesforceSDKManager.appContext)
720
-
721
-
// Prepare the Google Play Integrity token. Calling this prior to requesting the Integrity Token reduces the latency of the request.
722
-
integrityManager.prepareIntegrityToken(
723
-
PrepareIntegrityTokenRequest.builder()
724
-
.setCloudProjectNumber(cloudProjectNumber)
725
-
.build()
726
-
).addOnSuccessListener { tokenProvider ->
727
-
integrityTokenProvider = tokenProvider
728
-
Log.i("AppAttestation", "Prepared Google Play Integrity Token Provider: '${tokenProvider}'.")
729
-
}.addOnFailureListener { exception ->
730
-
Log.e("AppAttestation", "Failed to prepare Google Play Integrity Token Provider: '${exception.message}'.")
731
-
}
732
-
}
733
-
}
734
-
735
-
/**
736
-
* A simple proof-of-concept for fetching the Salesforce App Attestation
737
-
* ECA Plug-In's "Challenge".
738
-
* @return The Salesforce App Attestation ECA Plug-In's "Challenge"
val googlePlayIntegrityTask = integrityTokenResponse.addOnSuccessListener { response ->
777
-
Log.i("AppAttestation", "Received Google Play Integrity Token: '${response.token()}'.")
778
-
779
-
}.addOnFailureListener { exception ->
780
-
// If the app uses the same token provider for too long, the token provider can expire which results in the INTEGRITY_TOKEN_PROVIDER_INVALID error on the next token request. You should handle this error by requesting a new provider.
781
-
Log.e("AppAttestation", "Failed To Receive Google Play Integrity Token: Message: '${exception.message}'.")
782
-
783
-
// TODO: Handle the error by requesting a new Google Play Integrity Token Provider. ECJ20260311
784
-
}
785
-
786
-
// Wait for the Google Play Integrity API response and return the Base64-encoded Salesforce OAuth authorization attestation parameter JSON.
0 commit comments