【发布时间】:2019-06-29 00:03:02
【问题描述】:
我正在使用 OAuth2 gem 来进行 client_credential 身份验证。我的代码如下,
require 'oauth2'
client = OAuth2::Client.new("my_client_id", "my_client_secret", :site => "my_site_url", :token_url => "oauth2/token")
client.client_credentials.get_token
当我执行上面的代码块时,它会响应以下错误,
OAuth2::Error (invalid_client: Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method))
{
"error":"invalid_client","error_description":"Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method)",
"error_hint":"The OAuth 2.0 Client supports client authentication method "client_secret_basic", but method "client_secret_post" was requested.
You must configure the OAuth 2.0 client's "token_endpoint_auth_method" value to accept "client_secret_post".","status_code":401}
我检查了使用 'net/http' 库,我的 client_id 和 client_secrets 有效且正常工作。
我看到的唯一问题是上述消息提示中所说的身份验证方法,
The OAuth 2.0 Client supports client authentication method "client_secret_basic", but method "client_secret_post" was requested. You must configure the OAuth 2.0 client's "token_endpoint_auth_method" value to accept "client_secret_post"
我想知道的是?
-
OAuth2gem 如何决定使用 client_secret_post 还是 client_secret_basic?我的意思是如何在 OAuth2 gem 中使用 client_secret_basic 请求? - 如果不是以上那么,我应该如何指定 token_endpoint_auth_method 来接受 client_secret_post?
【问题讨论】:
-
缺少报价。在stackoverflow或代码中粘贴时是否错过了它,请检查
-
这里只漏了,代码里有。
标签: ruby-on-rails ruby oauth oauth-2.0 net-http