使用Laravel Socialite作为API社交身份验证

问题描述

我想将#Laravel_Socialite用作我的#ionic应用程序的#API,但是服务器始终显示错误。 有人知道这个问题吗?我确定离子性功能有误,因为我在请求中未发布任何内容 请帮忙。

Laravel函数:

public function redirectToFacebook()
    {
        $url = Socialite::with('facebook')->stateless()->redirect()->getTargetUrl();
        return \response()->json([
            'url' => $url
        ],200);
    }

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function handleFacebookCallback()
    {
        try {
            $user = Socialite::with('facebook')->stateless()->user();;
            $create['name'] = $user->getName();
            $create['email'] = $user->getEmail();
            $create['facebook_id'] = $user->getId();
            

        } catch (Exception $e) {
            return \response()->json([
                'code' => $e->getCode(),'message' => 'error'
            ]);
        }
    }

Laravel路线:

enter image description here

Login.ts函数(离子):

fbLogin()
{
  this.fb.login(['public_profile','email'])
    .then(res => {
      if (res.status === 'connected') {
        this.isLoggedIn = true;
        console.log("detailsss");
        this.getUserDetail(res.authResponse.userID);
        this.authService.handleFacebookCallback().subscribe(
          res => { 
            console.log("accesstooooken2")
            console.log(res);
            },err => {
                 console.log(err);
            });
        console.log("res");
        console.log(res);
        this.route.navigate(['/home']);
      } else {
        this.isLoggedIn = false;
      }
    }),(error: any) => {
      console.log(error);  
    }}

服务功能:

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)