Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify.Auth.signInWithSocialWebUI logs in but MobileClient is not on version 2.14.6 #2713

Closed
1 task done
RoustamManookian opened this issue Feb 10, 2024 · 4 comments
Closed
1 task done
Labels
question General question

Comments

@RoustamManookian
Copy link

RoustamManookian commented Feb 10, 2024

Before opening, please confirm:

Language and Async Model

Kotlin

Amplify Categories

Authentication

Gradle script dependencies

// Put output below this line
implementation 'com.amplifyframework:core:2.14.6'
    implementation 'com.amplifyframework:aws-auth-cognito:2.14.6'
    implementation 'com.amplifyframework:aws-storage-s3:2.14.6'
    implementation('com.amazonaws:aws-android-sdk-cognitoauth:2.34.0@aar') { transitive=true }
    implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.73.0'
    implementation 'com.amazonaws:aws-android-sdk-auth-userpools:2.7.6'
// Google SignIn
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.amazonaws:aws-android-sdk-auth-google:2.73.0'

    // Sign in UI Library
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.amazonaws:aws-android-sdk-auth-ui:2.73.0'

implementation 'com.amplifyframework:core:2.14.6' implementation 'com.amplifyframework:aws-auth-cognito:2.14.6' implementation 'com.amplifyframework:aws-storage-s3:2.14.6' implementation('com.amazonaws:aws-android-sdk-cognitoauth:2.34.0@aar') { transitive=true } implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.73.0' implementation 'com.amazonaws:aws-android-sdk-auth-userpools:2.7.6' // Google SignIn implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.amazonaws:aws-android-sdk-auth-google:2.73.0'
// Sign in UI Library
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.amazonaws:aws-android-sdk-auth-ui:2.73.0'

Environment information

# Put output below this line


Please include any relevant guides or documentation you're referencing

No response

Describe the bug

I updated the Amplify framework version to 2
Before everything worked well, now the Amplify.Auth.signInWithSocialWebUI is completing with success but the MobileClient is not connecting and thus I can't use any AWS services like IOT or S3.

Reproduction steps (if applicable)

No response

Code Snippet

// Put your code below this line.
AWSMobileClient.getInstance().initialize(this, object : Callback<UserStateDetails> {
            override fun onResult(userStateDetails: UserStateDetails) {
                Logg.d("INIT", "🔑 ♥♥♥ MobileClient init, userState: -> ${userStateDetails.userState}")
                Logg.d("MobileClient", "🔑 ♥♥♥ MobileClient  isSigned in = ${AWSMobileClient.getInstance().isSignedIn}")

                Amplify.Auth.signInWithSocialWebUI(
                    AuthProvider.google(),
                    this@SocialSignInActivity,
                    {
                        Amplify.Auth.fetchAuthSession(
                            {
                                val session = it as AWSCognitoAuthSession
                                when (session.identityIdResult.type) {
                                    AuthSessionResult.Type.SUCCESS ->{
                                        Logg.d("AuthQuickStart", "🔑 isSignedIn = ${session.isSignedIn}")
                                        Logg.d("AuthQuickStart", "🔑 IdentityId = ${session.identityIdResult.value}")
                                        Logg.d("AuthQuickStart", "🔑 userPoolTokensResult = ${session.userPoolTokensResult.value}")
                                        Logg.d("AuthQuickStart", "🔑 tokensResult = ${session.tokensResult.value}")
                                        Logg.d("AuthQuickStart", "🔑 accessToken = ${session.accessToken}")
                                        Logg.d("AuthQuickStart", "🔑 awsCredentialsResult = ${session.awsCredentialsResult.value}")

                                        Logg.d("INIT", "🔑 ♥♥♥ MobileClient init, userState: -> ${userStateDetails.userState}")
                                        Logg.d("MobileClient", "🔑 ♥♥♥ MobileClient  isSigned in = ${AWSMobileClient.getInstance().isSignedIn}")
                                    }
                                    AuthSessionResult.Type.FAILURE -> {
                                        Logg.d("AuthQuickStart", "🔑 IdentityId not found. error = ${session.identityIdResult.error}")
                                        socialSignIn(true)
                                    }
                                }
                            },
                            {
                                Logg.d("AuthQuickStart", "🔑 Failed to fetch session, error = $it")
                                socialSignIn(true)
                            }
                        )
                    },
                    {
                        Logg.d("AuthQuickStart", "🔑 Signin failed, Error: $it")
                        if (it is UserCancelledException){
                            signIn()
                        }
                    }
                )
            }
            override fun onError(e: Exception) {
                Logg.d("INIT", "🔑❌ Error during initialization, Error: $e")
            }
        })

Log output

// Put your logs below this line
(SocialSignInActivity.kt:101) 🔑 isSignedIn = true
(SocialSignInActivity.kt:102) 🔑 IdentityId = us-east-2:xxxxxxxx
(SocialSignInActivity.kt:103) 🔑 userPoolTokensResult = AWSCognitoUserPoolTokens(accessToken=eyJr... idToken=eyJra... refreshToken=ey...
(SocialSignInActivity.kt:104) 🔑 tokensResult = AWSCognitoUserPoolTokens(accessToken=eyJraWQi... idToken=eyJbSE
(SocialSignInActivity.kt:105) 🔑 accessToken = eyJraW
(SocialSignInActivity.kt:106) 🔑 awsCredentialsResult = AWSTemporaryCredentials(accessKeyId=ASIAxxxxx, secretAccessKey=dGxxxxxx, sessionToken=IQoxxxxxx, sessionToken=IQoeIw, expiration=2024-02-10T19:54:36Z)
(SocialSignInActivity.kt:108) 🔑 ♥♥♥ MobileClient init, userState: -> SIGNED_OUT
KeyProvider23     AndroidKeyStore contains keyAlias com.amazonaws.mobile.client.aesKeyStoreAlias
KeyProvider23     Loading the encryption key from Android KeyStore.
KeyProvider23     AndroidKeyStore contains keyAlias com.amazonaws.mobile.client.aesKeyStoreAlias
KeyProvider23     Loading the encryption key from Android KeyStore.
KeyProvider23     AndroidKeyStore contains keyAlias com.amazonaws.mobile.client.aesKeyStoreAlias
KeyProvider23     Loading the encryption key from Android KeyStore.
KeyProvider23     AndroidKeyStore contains keyAlias com.amazonaws.mobile.client.aesKeyStoreAlias
KeyProvider23     Loading the encryption key from Android KeyStore.
AWSMobileClient  Inspecting user state details
(SocialSignInActivity.kt:109) 🔑 ♥♥♥ MobileClient  isSigned in = false

amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

No response

@tylerjroach
Copy link
Member

Hi @RoustamManookian Amplify Android v2 and the AWS Android SDK are not compatible with each other. While Amplify v1 was build on top the AWS Android SDK, Amplify v2 uses the AWS Kotlin SDK under the hood.

Please look into using the Amplify v2 Storage category for s3 operations. If Amplify Storage does not fit all of your use cases, you can use the escape hatch to eject into the Kotlin SDK: https://docs.amplify.aws/android/build-a-backend/storage/sdk/.

The IoT library from the AWS Android SDK can still continue to be used by passing a custom credentials provider that uses Amplify v2 to fetch credentials. Please see this example: #2400 (comment)

@tylerjroach tylerjroach added the question General question label Feb 12, 2024
@RoustamManookian
Copy link
Author

RoustamManookian commented Feb 14, 2024

Thank you @tylerjroach .
I had to call MqttManager connect function with credentioalsProvider instead of MobileClient.
awsIotManager?.connect(MyCredentialsProvider(), statusCallback)

I deleted 'com.amazonaws:aws-android-sdk-mobile-client:2.73.0' dependancy from gradle
Now everything is working perfect.

@tylerjroach
Copy link
Member

Great! Were you able to migrate storage? If not, you can also pass your credentials provider into TransferUtility.

val awsConfiguration = AWSConfiguration(context)
val transferUtility = TransferUtility.builder()
    .context(context)
    .awsConfiguration(awsConfiguration)
    .s3Client(
        AmazonS3Client(
            MyCredentialsProvider(),
            Region.getRegion(Regions.US_EAST_1)
        )
    )
    .build()

@tylerjroach tylerjroach added the closing soon This issue will be closed in 7 days unless further comments are made. label Feb 14, 2024
@github-actions github-actions bot removed the closing soon This issue will be closed in 7 days unless further comments are made. label Feb 26, 2024
Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question General question
Projects
None yet
Development

No branches or pull requests

2 participants