Skip to content

signInWithSocialWebUI throws a NullPointerException on 2.2.0 but not on 1.37.10 #2282

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

Closed
1 task done
MrBenjoo opened this issue Feb 8, 2023 · 6 comments
Closed
1 task done
Assignees
Labels
auth Related to the Auth category/plugins bug Something isn't working pending-community-response Issue is pending response from the issue requestor

Comments

@MrBenjoo
Copy link

MrBenjoo commented Feb 8, 2023

Before opening, please confirm:

Language and Async Model

Kotlin - Coroutines

Amplify Categories

Authentication

Gradle script dependencies

[versions]
amplify = "2.2.0"

[libraries]
com.amplifyframework:core-kotlin:2.2.0
com.amplifyframework:aws-auth-cognito:2.2.0

[gradle plugin]
com.amplifyframework:amplify-tools-gradle-plugin:1.0.2

Environment information

------------------------------------------------------------
Gradle 7.5
------------------------------------------------------------

Build time:   2022-07-14 12:48:15 UTC
Revision:     c7db7b958189ad2b0c1472b6fe663e6d654a5103

Kotlin:       1.6.21
Groovy:       3.0.10
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          1.8.0_275 (AdoptOpenJDK 25.275-b01)
OS:           Windows 10 10.0 amd64

Please include any relevant guides or documentation you're referencing

https://docs.amplify.aws/lib/auth/social/q/platform/android/#update-androidmanifestxml

Describe the bug

Calling Amplify.Auth.signInWithSocialWebUI(AuthProvider.google(), callingActivity) throws a nullpointerexception.

It works when using core-kotlin:0.21.10 and aws-auth-cognito:1.37.10, i am able to sign in without problems.

Reproduction steps (if applicable)

No response

Code Snippet

private suspend fun signInWithSocialWebUI(callingActivity: Activity) = try {
        Amplify.Auth.signInWithSocialWebUI(AuthProvider.google(), callingActivity)
        true
    } catch (exception: Exception) {
        false
    }

Log output

java.lang.NullPointerException at com.amplifyframework.auth.cognito.actions.AuthorizationCognitoActions$initializeFetchAuthSession$$inlined$invoke$1.execute(Action.kt:89) at com.amplifyframework.statemachine.ConcurrentEffectExecutor$execute$1$1.invokeSuspend(ConcurrentEffectExecutor.kt:26) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Suppressed:
kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@c4f97ba, Dispatchers.Default]

amplifyconfiguration.json

{
  "UserAgent": "aws-amplify-cli/2.0",
  "Version": "1.0",
  "auth": {
    "plugins": {
      "awsCognitoAuthPlugin": {
        "UserAgent": "aws-amplify-cli/0.1.0",
        "Version": "0.1.0",
        "IdentityManager": {
          "Default": {}
        },
        "CredentialsProvider": {
          "CognitoIdentity": {
            "Default": {
              "PoolId": "$poolIdCredentialsProvider",
              "Region": "$region"
            }
          }
        },
        "CognitoUserPool": {
          "Default": {
            "PoolId": "$poolIdCognito",
            "AppClientId": "$clientId",
            "AppClientSecret": "$clientSecret",
            "Region": "$region"
          }
        },
        "Auth": {
          "Default": {
            "OAuth": {
              "WebDomain": "$webDomain",
              "AppClientId": "$clientId",
              "AppClientSecret": "$clientSecret",
              "SignInRedirectURI": "$signInRedirectURI",
              "SignOutRedirectURI": "$signOutRedirectURI",
              "Scopes": [
                "email"
              ]
            },
            "authenticationFlowType": "USER_SRP_AUTH"
          }
        }
      }
    }
  }
}

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

Also, I never got this exception on version 2.0.0.

@MrBenjoo MrBenjoo changed the title signInWithSocialWebUI throws a NullPointerException on 2.2.0 but not on 1.37.5 signInWithSocialWebUI throws a NullPointerException on 2.2.0 but not on 1.37.10 Feb 8, 2023
@banji180 banji180 assigned banji180 and unassigned banji180 Feb 8, 2023
@mattcreaser mattcreaser added bug Something isn't working auth Related to the Auth category/plugins labels Feb 10, 2023
@banji180
Copy link
Contributor

@MrBenjoo we are not able to reproduce this issue. It seems in your case the token received on callback is null and that is not the expected behavior. We have a PR out to capture the NPE and display the error, but in the mean time, is other social plugins like facebook working?

@MrBenjoo
Copy link
Author

MrBenjoo commented Feb 13, 2023

@banji180 I am getting the same exception after signing in with apple or facebook. Maybe it is unrelated, but i am seeing this in the logs each time the exception is thrown:

win=Window{1bf7804 u0 com.android.project/com.amplifyframework.auth.cognito.activities.CustomTabsManagerActivity} destroySurfaces: appStopped=true win.mWindowRemovalAllowed=false win.mRemoveOnExit=false win.mViewVisibility=4 caller=com.android.server.wm.ActivityRecord.destroySurfaces:5867 com.android.server.wm.ActivityRecord.destroySurfaces:5848 com.android.server.wm.ActivityRecord.notifyAppStopped:5912 com.android.server.wm.ActivityRecord.activityStopped:6554 com.android.server.wm.ActivityClientController.activityStopped:254 android.app.IActivityClientController$Stub.onTransact:596 com.android.server.wm.ActivityClientController.onTransact:130

@banji180
Copy link
Contributor

ok thanks for the quick response, but I don't think this is the root cause. It seems the token is coming back as null, but since we are not able to reproduce, we are updating the SDK shortly to catch and display the token is null error. Once we release this update, we will update you.

@tjleing
Copy link
Contributor

tjleing commented Feb 17, 2023

We have released library version 2.2.2 to attempt to resolve this issue. Please let us know if that works for you!

@tjleing tjleing added the pending-community-response Issue is pending response from the issue requestor label Feb 17, 2023
@MrBenjoo
Copy link
Author

@tjleing Yes, it seems that it works now. Thanks!

@gpanshu gpanshu closed this as completed Feb 20, 2023
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Related to the Auth category/plugins bug Something isn't working pending-community-response Issue is pending response from the issue requestor
Projects
None yet
Development

No branches or pull requests

5 participants