我的php应用程序LinkedIn身份验证几天前停止工作。我不知道Linkedin在过去几天/几周内进行了一些API更改。
我收到此错误:
errorCode 0
message "Unknown authentication scheme"
requestId "FLI??????I"
status 401
timestamp 155821???845
我已经在StackOverflow和其他博客上检查了一些讨论过的问题,而没有找到解决方案。
我的回调函数代码的一部分(在init.php文件中):
function getCallback(){
$client_id = "8???????u";
$client_secret = "W????????r";
$redirect_uri = "https://mydomain-app.com/authenticate/callback.php";
$csrf_token = random_int(1111111, 9999999);
$scopes = "r_basicprofile r_emailaddress";
if( isset($_REQUEST['code'])) {
$code = $_REQUEST['code'];
$url = "https://www.linkedin.com/oauth/v2/accessToken";
$params = [
'client_id' => $client_id,
'client_secret' => $client_secret,
'redirect_uri' => $redirect_uri,
'code' => $code,
'grant_type' => 'authorization_code',
];
$accessToken = curl($url, http_build_query($params));
$obj = json_decode($accessToken);
$accessToken = $obj->access_token;
$url = "https://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-url,location,email-address)?format=json&oauth2_access_token=" . $accessToken;
$user = file_get_contents($url, false);
return(json_decode($user));
}
}
在callback.php文件中:
<?php
require_once "init.php";
$user = getCallback();
...
在login.php文件中:
...
<a href='<?php echo "https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id={$client_id}&redirect_uri={$redirect_uri}&state={$csrf_token}&scope={$scopes}";?>'>
...
我收到此错误:
errorCode 0
message "Unknown authentication scheme"
requestId "F????????I"
status 401
timestamp 155821???845
这里缺少什么吗?有什么想法吗? 感谢您的帮助。