PayPal OpenId Connect 沙盒元数据地址

PayPal OpenId Connect Sandbox Metadata Address

我正在尝试构建一个在沙盒中使用 PayPal 登录的 spike。我正在使用基于此 http://www.cloudidentity.com/blog/2014/07/24/protecting-an-asp-net-webforms-app-with-openid-connect-and-azure-ad/ 的 Microsoft.Owin.Security.OpenIdConnect 以获得更好的示例。

public void ConfigureAuth(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
        app.UseCookieAuthentication(new CookieAuthenticationOptions());

        app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {

                ClientId = "my test clientid",
                RedirectUri = "http://localhost:50625",
                Scope = "openid profile email address phone",
                Authority = "https://www.sandbox.paypal.com/signin/authorize",
                MetadataAddress = "https://www.paypalobjects.com/.well-known/openid-configuration"

            });

问题是元数据地址。

如果我将 MetadataAddress 设置为 https://www.paypalobjects.com/.well-known/openid-configuration 那么配置是实时的,我收到的授权 URL 是

https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=etc

这不是沙箱,从未听说过我的客户端 ID 并抛出错误。如果我然后按后退按钮,将 url 更改为

https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=etc

然后就可以了。

但是如果我将 MetadataAddress 设置为

http://www.sandbox.paypal.com/.well-known/openid-configuration

那么先

  1. 我得到一个错误 "The request was aborted: Could not create SSL/TLS secure channel."
  2. 无论如何,sandbox.paypal.com 中的文件与实时文件具有相同的配置。

使用 PayPal 沙箱登录的 .well-known/openid-configuration 的正确 url 是什么?

我使用

中的 Owin.Security.Providers.PayPal 找到了我需要的答案

https://github.com/TerribleDev/OwinOAuthProviders

它似乎没有使用.well-known/openid-configuration,但其中有以下端点。

    private const string AuthorizationEndPoint = "https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize";
    private const string TokenEndpoint = "https://api.paypal.com/v1/identity/openidconnect/tokenservice";
    private const string UserInfoEndpoint = "https://api.paypal.com/v1/identity/openidconnect/userinfo/?schema=openid";

    private const string SandboxAuthorizationEndPoint = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize";
    private const string SandboxTokenEndpoint = "https://api.sandbox.paypal.com/v1/identity/openidconnect/tokenservice";
    private const string SandboxUserInfoEndpoint = "https://api.sandbox.paypal.com/v1/identity/openidconnect/userinfo/?schema=openid";

我最终设法使用我的沙盒帐户登录。

其他尝试同样事情的人注意事项:

首先需要设置

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

在某些时候因为 The request was aborted: Could not create SSL/TLS secure channel sandbox account

其次,您在 PayPal 的应用程序设置中配置的 Return URL 需要是生成的整个回调 URL (不仅仅是域名),它不会实际上在任何地方都告诉你那将是什么......默认是

http://localhost[:$port]/signin-paypal