Exemple #1
0
        public string RefreshToken(String Code, string Token)
        {
            String AccessToken = null;

            byte[]         byte1     = Encoding.ASCII.GetBytes("grant_type=refresh_token&refresh_token=" + Token + "");
            HttpWebRequest bearerReq = WebRequest.Create("https://zoom.us/oauth/token") as HttpWebRequest;

            bearerReq.Accept                = "application/json";
            bearerReq.Method                = "POST";
            bearerReq.ContentType           = "application/x-www-form-urlencoded";
            bearerReq.ContentLength         = byte1.Length;
            bearerReq.KeepAlive             = false;
            bearerReq.UseDefaultCredentials = true;
            bearerReq.PreAuthenticate       = true;
            bearerReq.Credentials           = CredentialCache.DefaultCredentials;
            // bearerReq.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            bearerReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("xYQX5LqmSmmgs399u4cmXg" + ":" + "EGgWU3APKH0IVEZDxJYKDTRgb5q6kvfN")));
            Stream newStream = bearerReq.GetRequestStream();

            newStream.Write(byte1, 0, byte1.Length);
            WebResponse bearerResp = bearerReq.GetResponse();

            using (var reader = new StreamReader(bearerResp.GetResponseStream(), Encoding.UTF8))
            {
                var response = reader.ReadToEnd();
                ZoomTokenResponse ZoomTokenResponse = JsonConvert.DeserializeObject <ZoomTokenResponse>(response);
                AccessToken = ZoomTokenResponse.access_token;
            }

            return(AccessToken);
        }
Exemple #2
0
        public string GetToken(String Code)
        {
            String AccessToken = null;
            string URl         = "https://localhost:44328/Zoom/Index";

            byte[]         byte1     = Encoding.ASCII.GetBytes("grant_type=authorization_code&code=" + Code + "&redirect_uri=" + URl + "");
            HttpWebRequest bearerReq = WebRequest.Create("https://zoom.us/oauth/token") as HttpWebRequest;

            bearerReq.Accept                = "application/json";
            bearerReq.Method                = "POST";
            bearerReq.ContentType           = "application/x-www-form-urlencoded";
            bearerReq.ContentLength         = byte1.Length;
            bearerReq.KeepAlive             = false;
            bearerReq.UseDefaultCredentials = true;
            bearerReq.PreAuthenticate       = true;
            bearerReq.Credentials           = CredentialCache.DefaultCredentials;
            // bearerReq.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            bearerReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("UdeBtrjSp6gVUpwlwWL3w" + ":" + "mpLop8166lIcCnZH7UYahjtVXf4n5PU7")));
            Stream newStream = bearerReq.GetRequestStream();

            newStream.Write(byte1, 0, byte1.Length);
            WebResponse bearerResp = bearerReq.GetResponse();

            using (var reader = new StreamReader(bearerResp.GetResponseStream(), Encoding.UTF8))
            {
                var response = reader.ReadToEnd();
                ZoomTokenResponse ZoomTokenResponse = JsonConvert.DeserializeObject <ZoomTokenResponse>(response);
                AccessToken = ZoomTokenResponse.access_token;
            }

            return(AccessToken);
        }