我使用Happyr/LinkedIn-API-client在symfony框架中将Login与LinkedIn集成。但我得到无法获取访问令牌例外。
我正在附上例外的截图。
以下是我遇到错误的代码。
protected function fetchNewAccessToken()
{
$storage = $this->getStorage();
$code = $this->getCode();
if ($code !== null) {
$accessToken = $this->getAccessTokenFromCode($code);
if ($accessToken) {
$storage->set('code', $code);
$storage->set('access_token', $accessToken);
return $accessToken;
}
// code was bogus, so everything based on it should be invalidated.
$storage->clearAll();
throw new LinkedInApiException('Could not get access token');
}
// as a fallback, just return whatever is in the persistent
// store, knowing nothing explicit (signed request, authorization
// code, etc.) was present to shadow it (or we saw a code in $_REQUEST,
// but it's the same as what's in the persistent store)
return $storage->get('access_token', null);
}
答案 0 :(得分:0)
我建议你不要发明自行车。由于可能的安全漏洞,身份验证bycicle是最糟糕的事情。
只需使用已经实施的OAuth客户端,它支持interface HTMLElement {
add:(a:string)=>void; // error: add is duplicate
add:(a:boolean)=>void;
}
HTMLElement.prototype.add = function (a):void{
if(typeof a=="string"){
}
else if(typeof a=="boolean"){
}
}
class HTMLElement2 {
add(a:string):void; // ok
add(a:boolean):void;
add(a):void{
if(typeof a=="string"){
}
else if(typeof a=="boolean"){
}
}
}
作为身份验证提供程序。
我个人更喜欢LinkedIn
。这很简单。
https://github.com/hwi/HWIOAuthBundle
配置
HWIOAuthBundle