use of com.microsoft.identity.common.internal.ui.browser.CustomTabsManager in project microsoft-authentication-library-common-for-android by AzureAD.
the class CurrentTaskBrowserAuthorizationStrategy method requestAuthorization.
@Override
public Future<AuthorizationResult> requestAuthorization(GenericAuthorizationRequest authorizationRequest, GenericOAuth2Strategy oAuth2Strategy) throws ClientException {
final String methodName = ":requestAuthorization";
checkNotDisposed();
final Context context = getApplicationContext();
mOAuth2Strategy = oAuth2Strategy;
mAuthorizationRequest = authorizationRequest;
mAuthorizationResultFuture = new ResultFuture<>();
final Browser browser = BrowserSelector.select(context, mBrowserSafeList);
// ClientException will be thrown if no browser found.
Intent authIntent;
if (browser.isCustomTabsServiceSupported()) {
Logger.info(TAG + methodName, "CustomTabsService is supported.");
// create customTabsIntent
mCustomTabManager = new CustomTabsManager(context);
if (!mCustomTabManager.bind(context, browser.getPackageName())) {
// create browser auth intent
authIntent = new Intent(Intent.ACTION_VIEW);
} else {
authIntent = mCustomTabManager.getCustomTabsIntent().intent;
}
} else {
Logger.warn(TAG + methodName, "CustomTabsService is NOT supported");
// create browser auth intent
authIntent = new Intent(Intent.ACTION_VIEW);
}
authIntent.setPackage(browser.getPackageName());
final Uri requestUrl = authorizationRequest.getAuthorizationRequestAsHttpRequest();
authIntent.setData(requestUrl);
final Intent intent = buildAuthorizationActivityStartIntent(authIntent, requestUrl);
launchIntent(intent);
return mAuthorizationResultFuture;
}
Aggregations