在Symfony登录LinkedIn

时间:2016-05-19 10:04:30

标签: php api symfony linkedin

我使用Happyr/LinkedIn-API-client在symfony框架中将Login与LinkedIn集成。但我得到无法获取访问令牌例外。

我正在附上例外的截图。

enter image description here

以下是我遇到错误的代码。

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);
    }

1 个答案:

答案 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

LinkedIn文档: https://github.com/hwi/HWIOAuthBundle/blob/6c00622a9b87e475236949175f62bf4146c43216/Resources/doc/resource_owners/linkedin.md

配置

HWIOAuthBundle