aws-sdk-android icon indicating copy to clipboard operation
aws-sdk-android copied to clipboard

AuthClient: launchCustomTabs issue, 1 line called twice.

Open lolucosmin opened this issue 1 year ago • 8 comments

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.

lolucosmin avatar Jun 17 '24 10:06 lolucosmin

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 avatar Jun 17 '24 15:06 vincetran

@vincetran Hi, the main idea is we are using AWSMobileClient sdk, so we are calling AWSMobileClient.getInstance().showSignIn(activity, signInUIOptions, new Callback<UserStateDetails>() 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.

lolucosmin avatar Jun 21 '24 09:06 lolucosmin

@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

mhugot avatar Jun 21 '24 09:06 mhugot

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 avatar Jun 25 '24 20:06 vincetran

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)

vincetran avatar Jun 25 '24 21:06 vincetran

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.

mhugot avatar Jun 27 '24 08:06 mhugot

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

mhugot avatar Jul 16 '24 16:07 mhugot

@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 avatar Aug 14 '24 20:08 tylerjroach

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.

github-actions[bot] avatar Jan 14 '25 14:01 github-actions[bot]