Forum Libraries, Components, and Plugins

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Load SharePoint site-pages in Xamarin WebView with URL.

Goal
I am trying to load Sharepoint site pages in Xamarin WebView with URL like SharePoint Android/iOS app showing sitepages without asking user to log in at webview.

Progress
The app uses ADAL's AcquireTokenAsync() to get the access token from Azure AD and set the WebView source as SharePoint modern site pages URL. As the user first-time signs in to the app with AcquireTokenAsync(), the webview is load site page successfully.

Issue:
After the user closes and relaunches the app, it uses AcquireTokenSilentAsync() to authenticate. But when the webview loading the site page with URL, Microsoft ask the user to log in again at webview.

Notes
After authentication with AcquireTokenSilentAsync(), there are some cookies missing in CookieManager and NSHttpCookieStorage.
I also tried with MSAL and the issue still persist.

Question
Why there are cookies missing when the app using AcquireTokenSilentAsync(). How can achieve the goal without asking user to log in twice?

Here is some snapshot of code for authentication and webview.

    var platformParams = new PlatformParameters((Activity)Forms.Context);
try
{
    authResult = await authContext.AcquireTokenSilentAsync(resource, clientId);
}
    catch (Exception)
    {
        authResult = await authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
    }

var sitePageWebView = new WebView
{
    Source = "https://company.sharepoint.com/SitePages/page-title.aspx",
            MinimumHeightRequest = 1000,
            HorizontalOptions = LayoutOptions.FillAndExpand
 };
Sign In or Register to comment.