Paypal OAuth login example doesn't work as expected

前端 未结 5 1981
不思量自难忘°
不思量自难忘° 2021-01-15 05:06

I\'m following this interactive login example from Paypal\'s site.

  public ActionResult PaypalResponse(string scope, string code)
    {
        Dictionary&l         


        
5条回答
  •  -上瘾入骨i
    2021-01-15 05:38

    Sailen's answer above worked for me. However, because Paypal changed their encryption to TLS in June 2016, the solution as it was written will return the following error

    The request was aborted: Could not create SSL/TLS secure channel.

    Based on answers provided in another thread, the SecurityProtocol needs to be set to Tls12 before creating the WebRequest. Hope this helps someone.

    Here's a snippet.

    var postBody = $"grant_type=authorization_code&code={code}";
    
    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
    
    var authRequest = (HttpWebRequest)WebRequest.Create(oAuthUrl);
    

提交回复
热议问题