无法获取访问令牌和刷新令牌

时间:2019-12-05 04:57:59

标签: c# asp.net asp.net-web-api oauth-2.0 restsharp

所有放置在 try: with h5py.File(self.datapath, 'w') as hf: hf.create_dataset('saliencys', data=sal_maps) hf.create_dataset('probs', data=probs) hf.create_dataset('preds', data=preds) hf.close() del sal_maps,probs,preds sal_maps = np.array([], dtype=np.float32).reshape((0,) + img_size) probs = np.array([], dtype=np.float32) preds = np.array([], dtype=np.uint8) gc.collect() except: print('except->{}'.format(sal_maps.shape[0])) with h5py.File(self.datapath, 'a') as hf: hf["saliencys"].resize((hf["saliencys"].shape[0] + sal_maps.shape[0])) hf['saliencys'][-sal_maps.shape[0]:] = sal_maps hf['probs'].resize(hf['probs'].shape[0] + sal_maps.shape[0]) hf['probs'][-probs.shape[0]:] = probs hf['preds'].resize(hf['preds'].shape[0] + preds.shape[0]) hf['preds'][-preds.shape[0]:] = preds del sal_maps,probs,preds hf.close() sal_maps = np.array([], dtype=np.float32).reshape((0,) + img_size) probs = np.array([], dtype=np.float32) preds = np.array([], dtype=np.uint8) gc.collect() print("done appending....") sal_maps = np.array([], dtype=np.float32).reshape((0,) + img_size) probs = np.array([], dtype=np.float32) preds = np.array([], dtype=np.uint8) print('Save_saliency_maps::',idx) 中的ClientID,ClientSecret和RedirectURI。

web.config

现在从这里我得到了验证码。

<appSettings>      
    <add key="redirectURI" value="http://localhost:55593/oauthplayground" />
    <add key="clientId" value="uX4YpHHNm****ltekoG" />
    <add key="clientSecret" value="K5cSv3izT1GZ9PXnaWWfRWbTv10*****O3JkYFMlWMF3FhBtjyk0FqJduGJZSAL7B1DngJyxgX3KKNSD0Bqdv" />    
</appSettings>

然后我得到了我的授权码:

static string redirectURI = ConfigurationManager.AppSettings["redirectURI"];
static string clientID = ConfigurationManager.AppSettings["clientID"];
static string clientSecret = ConfigurationManager.AppSettings["clientSecret"];

protected void btnclick_Click(object sender, EventArgs e)
{
    Response.Redirect(String.Format("https://d****o.com/o/authorize/?response_type=code&client_id={0}&redirect_uri={1}", clientID, redirectURI));
}

(我将此代码存储在标签中,即3Q8tvb9d0fj232NZZIAIaItUIqtAd7

然后使用Access_token和Refresh令牌,我使用以下代码:

lblcode.Text

但是我遇到一个错误:

  

请求已中止:无法创建SSL / TLS安全通道。

注意

  • 使用POSTMAN,我得到了所有数据。这意味着所有API都在工作 正确地。
  • 在代码中列出项目注释,我使用了这些,但存在相同的问题 发生者。
  • 我还使用IISCrypto.exe检查了系统,其中 可以查看我所有的服务器,客户端协议(SSL 2.0,SSL 3.0,TLS 1.0, 启用了TLS 1.1,TLS 1.2)。

1 个答案:

答案 0 :(得分:1)

将此代码放在

上方
ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; 

以下代码。
 var request = WebRequest.Create("https://drchrono.com/o/token/");'