问题描述
为了获得oAuth2令牌,我必须通过发送vod connection::OnDataConnection(int status) {
}
error: ‘_1’ was not declared in this scope
sig.connect(boost::bind(&connection::OnDataConnectionDone,this,_1));
通过以下URL连接到REST API:https://abcd/api/oauth/v1/token
。请注意,此外,对base64_encode(api_client_id:api_secret)
的访问受到htpwd的保护。
所以我用PHP编写的请求是:
https://abcd/api/oauth/v1/token
但是Nginx服务器返回错误401。如何解决此错误?
我测试了不同的值,而不是$base64_encoded_client_id_and_secret = base64_encode('api_client_id:api_secret');
$curl_session = curl_init();
curl_setopt($curl_session,CURLOPT_URL,'https://abcd/api/oauth/v1/token');
curl_setopt($curl_session,CURLOPT_HTTPHEADER,['Content-Type: application/json','Authorization: Basic ' . $base64_encoded_client_id_and_secret]);
curl_setopt($curl_session,CURLOPT_HTTPAUTH,CURLAUTH_DIGEST);
curl_setopt($curl_session,CURLOPT_USERPWD,"htpwd_user:htpwd_pwd");
curl_setopt($curl_session,CURLOPT_POST,true);
curl_setopt($curl_session,CURLOPT_POSTFIELDS,[
'grant_type' => 'password','username' => 'api_user','password' => 'api_pwd'
]);
$ret = json_decode(curl_exec($curl_session));
;没有一个。
这是CROOS起源的问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)