【发布时间】:2018-11-04 00:51:38
【问题描述】:
我正在尝试在我的 coinbase 应用程序中设置 OAuth。在回调重定向中授权后我遇到了问题。
我有一个像这样的 .Net-Core 应用程序设置:
public const string COINBASE_AUTH_ID = "coinbase";
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = COINBASE_AUTH_ID;
})
.AddCookie()
.AddOAuth(COINBASE_AUTH_ID, options =>
{
options.ClientId = Configuration["Coinbase:ClientId"];
options.ClientSecret = Configuration["Coinbase:ClientSecret"];
options.CallbackPath = new PathString("/signin-coinbase");
options.AuthorizationEndpoint = "https://www.coinbase.com/oauth/authorize";
options.TokenEndpoint = "http://www.coinbase.com/oauth/token";
options.SaveTokens = true;
//...
点击授权按钮后,我被重定向到我的回调 url:localhost/signin-coinbase 那里我收到一个错误:
异常:OAuth 令牌端点失败:状态:未找到;标头:缓存控制:无存储、必须重新验证、无缓存、私有
在错误的正文部分,有一条消息:
正文:无效请求。而不是 GET 请求,您应该使用有效的 POST 参数进行 POST。更多信息请见https://developers.coinbase.com/docs/wallet/coinbase-connect;
编辑
这个错误发生在Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler
我推测原因是身份验证处理程序正在向/oauth/token api 发出获取请求,但它应该在发帖,有什么想法吗?
我应该尝试使用 Oidc 吗?
【问题讨论】:
标签: c# oauth-2.0 .net-core coinbase-api