public void ParseTokenFromUrl(string url)
        {
            if (url.Contains("access_token="))
            {
                var accessToken = url.Split("access_token=")[1].Split("&")[0];
                using (var db = new CacheDbContext())
                {
                    db.SessionInfo.Add(new SessionInfo
                    {
                        AccessToken = accessToken
                    });
                    db.SaveChanges();
                }

                VkObjects.InitializeApi();
                (Window.Current.Content as Frame)?.Navigate(typeof(MainPage));
            }
        }
Beispiel #2
0
        private void LoginWebView_OnNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
        {
            var authUri = args.Uri.ToString();

            if (authUri.Contains("access_token="))
            {
                var accessToken = authUri.Split("access_token=")[1].Split("&")[0];
                Console.WriteLine($"Token is: {accessToken}");
                using (var db = new CacheDbContext())
                {
                    db.SessionInfo.Add(new SessionInfo
                    {
                        AccessToken = accessToken
                    });
                    db.SaveChanges();
                }

                VkObjects.InitializeApi();
                Frame.Navigate(typeof(MainPage));
            }
        }