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

AuthClient: launchCustomTabs issue, 1 line called twice. #3597

Open
lolucosmin opened this issue Jun 17, 2024 · 8 comments
Open

AuthClient: launchCustomTabs issue, 1 line called twice. #3597

lolucosmin opened this issue Jun 17, 2024 · 8 comments
Labels
bug Something isn't working cognito Issues with the AWS Android SDK for Cognito

Comments

@lolucosmin
Copy link

State your question
Why in AuthClient when we call launchCustomTabs the line 473 is called twice ( activity.startActivityForResult(CustomTabsManagerActivity.createStartIntent(this.context, this.mCustomTabsIntent.intent), 49281)),
but only this line. The function is called 1 time.
Because is called twice the webpage is failing to load the correct sign in session.

Which AWS Services are you utilizing?
cognitoauth: version 2.75.2.

Provide code snippets (if applicable)

Environment(please complete the following information):

  • SDK Version: [e.g. 2.75.2]

Device Information (please complete the following information):

  • Device: [e.g. All devices]

If you need help with understanding how to implement something in particular then we suggest that you first look into our developer guide. You can also simplify your process of creating an application, as well as the associated backend setup by using the Amplify CLI.

@vincetran
Copy link
Member

launchCustomTabs is a private method so can you share with us the public method you're calling? It would also be beneficial to see a code snippet of that too. Have you tried adding some breakpoints to see the code path?

@vincetran vincetran added pending-community-response Issue is pending response from the issue requestor cognito Issues with the AWS Android SDK for Cognito labels Jun 17, 2024
@lolucosmin
Copy link
Author

@vincetran Hi, the main idea is we are using AWSMobileClient sdk, so we are calling AWSMobileClient.getInstance().showSignIn(activity, signInUIOptions, new Callback() and we pass some parameters. If you follow the flow at the end there is a function private void launchCustomTabs(Uri uri, Activity activity, String browserPackage) ; So we are passing a sso url to sign in, but weird thing is line 473: activity.startActivityForResult(CustomTabsManagerActivity.createStartIntent(this.context, this.mCustomTabsIntent.intent), 49281); is called twice.

@mhugot
Copy link

mhugot commented Jun 21, 2024

@vincetran more details about that, i work with @lolucosmin :

  • we have integrated an external openid provider in cognito userpool (akamai sso)
  • the login/authorize webview of the provider is displayed correctly
  • we enter email/password to the webview, then submit
  • but while webview is working to redirect to scheme://signin, the webview load another time the login url

we added breakpoint to understand what is happening and we saw that startActivityForResult is called two times
since akamai use crsf token in their url, it makes an error
with aws ios sdk, we dont have this issue

@vincetran
Copy link
Member

Thanks for the response @lolucosmin and @mhugot. As I investigate a little further, just wanted to first inquire if you're integrating auth using aws-sdk-android for the first time in your app. I ask because we suggest new integrations to use Amplify Android instead.

@vincetran vincetran removed the pending-community-response Issue is pending response from the issue requestor label Jun 25, 2024
@vincetran
Copy link
Member

Also, can you clarify this statement:

since akamai use crsf token in their url, it makes an error

What kind of error? (The exact stacktrace would be helpful)

@mhugot
Copy link

mhugot commented Jun 27, 2024

Hello,
It's a white label app used by many customer, so we are working on migration, but extra steps are required before we can migrate to Amplify.
For the error : basically we are calling the authorize url, then it redirect to a unique url with a token. If this url with token is called multiple times, it throw a 403 error.

@phantumcode phantumcode added the bug Something isn't working label Jul 1, 2024
@mhugot
Copy link

mhugot commented Jul 16, 2024

hello @vincetran @phantumcode
i see you added bug label, have you reproduced the issue?
when do you think you can fix that?
thanks

@tylerjroach tylerjroach added the pending-maintainer-response Issue is pending response from an Amplify team member label Aug 13, 2024
@tylerjroach
Copy link
Member

@mhugot Would it be possible to step back even further during debugging and see what is triggering launchCustomTabs 2 times in your use case.

For example, launchCustomTabs is only called within AuthClient launchCognitoAuth and launchSignOut. I assume signOut is not relevant here, so we can then look at launchCognitoAuth usages.

launchCognitoAuth is called within AuthClient getSession and refreshSession. Can you set a breakpoint on these methods and to see how launchCustomTabs is eventually called twice?

Thank you!

@tylerjroach tylerjroach removed the pending-maintainer-response Issue is pending response from an Amplify team member label Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cognito Issues with the AWS Android SDK for Cognito
Projects
None yet
Development

No branches or pull requests

5 participants