accessToken = $options['access_token']; // Some providers (not many) give the uid here, so lets take it isset($options['uid']) and $this->uid = $options['uid']; // Vkontakte uses user_id instead of uid isset($options['user_id']) and $this->uid = $options['user_id']; // Mailru uses x_mailru_vid instead of uid isset($options['x_mailru_vid']) and $this->uid = $options['x_mailru_vid']; // We need to know when the token expires. Show preference to // 'expires_in' since it is defined in RFC6749 Section 5.1. // Defer to 'expires' if it is provided instead. if (!empty($options['expires_in'])) { $this->expires = time() + ((int) $options['expires_in']); } elseif (!empty($options['expires'])) { // Some providers supply the seconds until expiration rather than // the exact timestamp. Take a best guess at which we received. $this->expires = ($options['expires'] > time()) ? $options['expires'] : time() + ((int) $options['expires']); } // Grab a refresh token so we can update access tokens when they expires isset($options['refresh_token']) and $this->refreshToken = $options['refresh_token']; } /** * Returns the token key. * * @return string */ public function __toString() { return (string) $this->accessToken; } }