Пример #1
0
        private async void OnNavigating(object sender, WebNavigatingEventArgs args)
        {
            if (args.Url.StartsWith("black://localhost/auth/spotify", StringComparison.CurrentCulture))
            {
                web.Navigating -= OnNavigating;

                var uri = new Uri(args.Url);
                if (uri.Query.StartsWith("?code=", StringComparison.CurrentCulture))
                {
                    string code = uri.Query.TrimStart('?').Split('&').First().Split('=').LastOrDefault();

                    AuthorizationCodeAuth auth = await AuthorizationCodeAuth.GetToken(code);

                    Application.Current.Resources["auth"]  = auth;
                    Application.Current.Properties["auth"] = auth.RefreshToken;
                    await Application.Current.SavePropertiesAsync();

                    Application.Current.MainPage = new NavigationPage(new IndexPage());
                }
            }
        }