使用HybridAuth时缺少redirect_uri参数和无效的grant_type

时间:2019-10-30 12:26:32

标签: php hybridauth

我已经在Google项目和Facebook上的暂存应用程序中设置了一些凭据,为每个凭据使用了正确的凭据,并在PHP应用程序上使用了Hybridauth,但我却不断收到Facebook的“缺少redirect_uri参数”错误和“无效的grant_type” Google的错误”。为Google和Facebook使用不同的凭据集在我的本地设置上都可以正常使用。当我交换凭据并上传到登台服务器时,就遇到了这个问题。任何帮助都将非常感谢。

      class HybridAuth {    

    /**
     * @return
     */

    public function getUserProfile($platform = 'facebook', $withBooking = false) {
      $withBooking = ($withBooking) ? '&withBooking=true' : '';
      $config = [ 'callback' => config('app.url.fullyQualifiedDomain') . '/auth/social-login?platform=' . $platform . $withBooking,
                    'keys'  => ['id' => config('vendors.' . $platform . '.keys.appId'),
                                  'secret' => config('vendors.' . $platform . '.keys.appSecret')]];

      $hybridauth = $this->$platform($config);

      try {
        $hybridauth->authenticate();
        $isConnected = $hybridauth->isConnected();        
        if($isConnected){
          $userProfile = $hybridauth->getUserProfile();
          $hybridauth->disconnect();
          return $userProfile;
        }
        return false;
      } catch(\Exception $e) {
        trigger_error(get_class($e) . ': ' . $e->getMessage() . '<br /><br />' . $e->getTraceAsString(), E_USER_ERROR);
      }
    }


    private function facebook($config) {
      return new \Hybridauth\Provider\Facebook($config);
    }


    private function google($config) {
      return new \Hybridauth\Provider\Google($config);
    }
  }

0 个答案:

没有答案
相关问题