Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Fix failing auth redirect on Android #2090

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public partial class WebAuthenticator
static TaskCompletionSource<WebAuthenticatorResult> tcsResponse = null;
static Uri currentRedirectUri = null;

internal static bool AuthenticatingWithCustomTabs { get; private set; } = false;

internal static bool OnResume(Intent intent)
{
// If we aren't waiting on a task, don't handle the url
Expand Down Expand Up @@ -71,7 +73,11 @@ static async Task<WebAuthenticatorResult> PlatformAuthenticateAsync(WebAuthentic
tcsResponse = new TaskCompletionSource<WebAuthenticatorResult>();
currentRedirectUri = callbackUrl;

if (!(await StartCustomTabsActivity(url)))
// Try to start with custom tabs if the system supports it and we resolve it
AuthenticatingWithCustomTabs = await StartCustomTabsActivity(url);

// Fall back to using the system browser if necessary
if (!AuthenticatingWithCustomTabs)
{
// Fall back to opening the system-registered browser if necessary
var urlOriginalString = url.OriginalString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);

// start the intermediate activity again with flags to close the custom tabs
var intent = new Intent(this, typeof(WebAuthenticatorIntermediateActivity));
intent.SetData(Intent.Data);
intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
StartActivity(intent);
// Check how we launched the flow initially
if (WebAuthenticator.AuthenticatingWithCustomTabs)
{
// start the intermediate activity again with flags to close the custom tabs
var intent = new Intent(this, typeof(WebAuthenticatorIntermediateActivity));
intent.SetData(Intent.Data);
intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
StartActivity(intent);
}
else
{
// No intermediate activity if we returned from a system browser
// intent since there's no custom tab instance to clean up
WebAuthenticator.OnResume(Intent);
}

// finish this activity
Finish();
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pr:
- develop

variables:
BASE_VERSION: 1.7.1
BASE_VERSION: 1.8.0
PREVIEW_LABEL: 'ci'
BUILD_NUMBER: $[counter(format('{0}_{1}_{2}', variables['BASE_VERSION'], variables['PREVIEW_LABEL'], variables['Build.SourceBranch']), 1)]
NUGET_VERSION: $[format('{0}-{1}.{2}', variables['BASE_VERSION'], variables['PREVIEW_LABEL'], variables['BUILD_NUMBER'])]
Expand Down