Nodge / yii-eauth

EAuth extension allows to authenticate users by the OpenID, OAuth 1.0 and OAuth 2.0 providers.
BSD 2-Clause "Simplified" License
327 stars 114 forks source link

Undefined index: access_token in /var/www/html/protected/extensions/eauth/services/FacebookOAuthService.php(90) #110

Closed rahuldebsarder closed 7 years ago

rahuldebsarder commented 7 years ago

Undefined index: access_token because i have got: $token = array ( [{"access_token":"EAAZA1CJKCPiMBAIamWdYhAPnC4Ydz63VVvumf0qYDZB7FzHCaFjRXgeZCiI1JYCaBiYHKaR4wKTdBfO1ku3jGfQA0J55ZAibUgDYnUxp5iAgLkHlWbdUCXXNuXu4LEhd9bX2P8DlEPvCnMVc4yy1dt8Pks7HouNBbAZCrXahOLAZDZD","token_type":"bearer","expires_in":5173282}] => );

So create Undefined index: access_token error in this line: $this->setState('auth_token', $token['access_token']);

rahuldebsarder commented 7 years ago

I have fixed this issue by modify saveAccessToken function

protected function saveAccessToken($token) {

    if(isset($token['access_token'],$token['expires']))
    {
        $this->setState('auth_token', $token['access_token']);
        $this->setState('expires', isset($token['expires']) ? time() + (int)$token['expires'] - 60 : 0);
        $this->access_token = $token['access_token'];
    }else{
        $token2 = array_keys($token);
        if(isset($token2[0]))
        {
            $token_v2 = json_decode($token2[0],1);
            if(isset($token_v2['access_token'],$token_v2['expires_in']))
            {
                $this->setState('auth_token', $token_v2['access_token']);
                $this->setState('expires', isset($token_v2['expires_in']) ? time() + (int)$token_v2['expires_in'] - 60 : 0);
                $this->access_token = $token_v2['access_token'];
            }
        }
    }
}
ar3131 commented 7 years ago

Same problem!!!

tomaszbrunarski commented 7 years ago

same

Nodge commented 7 years ago

Fixed in v1.2.0