简体   繁体   English

PayPal OpenId Connect沙盒元数据地址

[英]PayPal OpenId Connect Sandbox Metadata Address

I'm trying to build a spike that uses Log In with PayPal in the sandbox. 我正在尝试建立一个在沙箱中使用“使用PayPal登录”的峰值。 I'm using Microsoft.Owin.Security.OpenIdConnect based on this http://www.cloudidentity.com/blog/2014/07/24/protecting-an-asp-net-webforms-app-with-openid-connect-and-azure-ad/ for want of a better example. 我正在根据此http://www.cloudidentity.com/blog/2014/07/24/protecting-an-asp-net-webforms-app-with-openid-connect-使用Microsoft.Owin.Security.OpenIdConnect 和azure-ad /缺少更好的例子。

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"

            });

The problem is the MetadataAddress. 问题是MetadataAddress。

If I set the MetadataAddress to https://www.paypalobjects.com/.well-known/openid-configuration then the configuration is for live, and the authorisation URL I get sent to is 如果我将MetadataAddress设置为https://www.paypalobjects.com/.well-known/openid-configuration,则该配置为实时运行,而发送到的授权URL为

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

which is not the sandbox and has never heard of my client id & throws an error. 这不是沙盒,并且从未听说过我的客户端ID并抛出错误。 If I then press the back button, change the url to 如果再按返回按钮,则将网址更改为

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

then it works. 然后就可以了。

But if I set the MetadataAddress to 但是如果我将MetadataAddress设置为

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

in the first place then 首先

  1. I get an error "The request was aborted: Could not create SSL/TLS secure channel." 我收到错误消息“请求已中止:无法创建SSL / TLS安全通道。”
  2. That file at sandbox.paypal.com has the same config as the live file anyway. 不管怎么说,sandbox.paypal.com上的该文件具有与实时文件相同的配置。

What is the correct url for the .well-known/openid-configuration for the Log In with PayPal sandbox? 使用PayPal登录沙箱的.well-known / openid-configuration正确的URL是什么?

I found the answer I needed by using Owin.Security.Providers.PayPal from 我通过使用来自以下位置的Owin.Security.Providers.PayPal找到了所需的答案

https://github.com/TerribleDev/OwinOAuthProviders https://github.com/TerribleDev/OwinOAuthProviders

It doesn't seem to use the .well-known/openid-configuration, but has the following end-points in it. 它似乎没有使用.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";

I eventually manged to get login working with my sandbox account. 最终,我设法使用我的沙箱帐户登录。

Notes for anyone else attempting the same thing: 其他尝试相同操作的人的注意事项:

Firstly, it's necessary to set 首先,有必要设置

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

at some point because of The request was aborted: Could not create SSL/TLS secure channel sandbox account 在某些时候由于请求被中止:无法创建SSL / TLS安全通道沙箱帐户

Secondly, the Return URL you configure in the App Settings in PayPal needs to be the WHOLE callback URL (not just the domain name) that's generated, and it doesn't actually tell you anywhere what that's going to be... the default is 其次,您在PayPal的“应用程序设置”中配置的Return URL必须是生成的WHOLE回调URL(不仅是域名),而且实际上并没有告诉您任何情况……默认值为

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM