Example #1
0
        private async void CompletedNav(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            String[] res = args.Uri.ToString().Substring(args.Uri.ToString().IndexOf('#') + 1).Split('=');

            using (HttpClient client = new HttpClient())
            {
                var values = new Dictionary <string, string>
                {
                    { "client_id", "4c87c24c218e973" },
                    { "client_secret", "93e8a179129b8393c0256c60a57a0abd40da4b6b" },
                    { "grant_type", "authorization_code" },
                    { "code", res[1] }
                };
                FormUrlEncodedContent content = new FormUrlEncodedContent(values);
                var response = await client.PostAsync("https://api.imgur.com/oauth2/token", content);

                string ret = await response.Content.ReadAsStringAsync();

                Debug.WriteLine(ret);
                client_info = JsonConvert.DeserializeObject <Imgur_client>(ret);
                if (client_info.account_id != 0)
                {
                    this.Frame.Navigate(typeof(HomeImgur), client_info);
                }
                else
                {
                    Imgur_Request request = JsonConvert.DeserializeObject <Imgur_Request>(ret);
                    Response.Text = "Error : " + request.data.error;
                }
            }
        }
Example #2
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     Imgur            = e.Parameter as Imgur_client;
     textMessage.Text = "User : " + Imgur.account_username;
 }