コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: buzenm/CNBlogsAPP1
        private void UserAppBarButton_Click(object sender, RoutedEventArgs e)
        {
            //HttpClient httpClient = new HttpClient();
            Uri uri1 = new Uri("https://oauth.cnblogs.com/connect/token");
            //HttpWebRequest httpWebRequest = null;
            //httpWebRequest = WebRequest.Create(uri) as HttpWebRequest;
            //httpWebRequest.Method = "POST";
            Client_Credentials client_Credentials = new Client_Credentials()
            {
                client_id     = "f52a0cdc-479a-4613-b2fa-8afeeeb04075",
                client_secret = "FxJS18UE3NgjsjqiKATnVamoX3_TFgsme6rtn0zIIAv32-wUJUI2Gdmm2KpNjAbluRG9OREVDJRnObe1", grant_type = "client_credentials"
            };
            string token = MyInternet.Post(uri1.ToString(), CNBlogsAPIClassToDic.GetToken((client_Credentials)));

            Uri uri2 = new Uri("https://oauth.cnblogs.com/connect/authorize");

            string[]  str       = token.Split(':');
            Authorize authorize = new Authorize()
            {
                client_id     = "f52a0cdc-479a-4613-b2fa-8afeeeb04075",
                scope         = "openid profile CnBlogsApi",
                response_type = "code id_token",
                redirect_uri  = "https://oauth.cnblogs.com/auth/callback",
                state         = "cnblogs.com",
                nonce         = "cnblogs.com"
            };

            string loginUri = MyInternet.Get(uri2.ToString(), CNBlogsAPIClassToDic.GetCode(authorize));

            ContentFrame.Navigate(typeof(SignPage));
            SignPage.current.SignWebView.Navigate(new Uri(loginUri));
        }
コード例 #2
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     if (e.Parameter is string)
     {
         Authorization_Code authorization_Code = new Authorization_Code()
         {
             grant_type    = "authorization_code",
             code          = (string)(e.Parameter),
             client_id     = "f52a0cdc-479a-4613-b2fa-8afeeeb04075",
             redirect_uri  = "https://oauth.cnblos.com/auth/callback",
             client_secret = "FxJS18UE3NgjsjqiKATnVamoX3_TFgsme6rtn0zIIAv32-wUJUI2Gdmm2KpNjAbluRG9OREVDJRnObe1"
         };
         string result = MyInternet.Post("https://oauth.cnblogs.com/connect/token", CNBlogsAPIClassToDic.GetAccess(authorization_Code));
     }
 }