如何在webview中显示auth0客户端loginasync

时间:2016-06-29 19:39:18

标签: c# xaml winrt-xaml auth0

我正在尝试使用登录页面构建一个使用auth0的应用程序,现在当我调用LoginAsync时,sdk将在不同的框架中弹出登录页面,我想在xaml中定义的webview中显示登录页面。

我想在这个定义的webview中显示此[[{0}}]中弹出的登录页面是xaml:

<Page
    x:Class="Auth0App.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Auth0App"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <StackPanel Margin="10,0">
        <StackPanel>
            <TextBlock Style="{ThemeResource SubheaderTextBlockStyle}">Log in using widget</TextBlock>
            <Grid HorizontalAlignment="Center" Margin="0,10">
                <Button Content="Login" x:Name="LoginButton" Click="LoginButton_OnClick"/>
            </Grid>
        </StackPanel>
        <StackPanel>
            <WebView Name="loginWebView"/>
        </StackPanel>
    </StackPanel>
</Page>

后面的代码是:

using Auth0.SDK;
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;


namespace Auth0App
{
    public sealed partial class MainPage : Page
    {
        private Auth0Client auth0Client;

        public MainPage()
        {
            this.InitializeComponent();
            auth0Client = new Auth0Client("mydomain", "**************************");
        }

        private async void LoginButton_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var user = await auth0Client.LoginAsync();
            }
            catch (Exception ex)
            {

            }
        }
    }
}

如何使用我的webview连接auth0客户端?

1 个答案:

答案 0 :(得分:0)

我首先看一下the Auth0 quickstart这个项目。我认为你已经到了中途,而快速启动会让你完成剩下的工作。

如果有任何遗失或您需要进一步的帮助,请随时与我们联系!

- Kassandra Perch,开发者布道者