Angular 角度ng2 ui身份验证和流明社交名流不匹配请求帖子
ng2 ui auth就是这样配置的Angular 角度ng2 ui身份验证和流明社交名流不匹配请求帖子,angular,lumen,laravel-socialite,satellizer,Angular,Lumen,Laravel Socialite,Satellizer,ng2 ui auth就是这样配置的 Ng2UiAuthModule.forRoot({ baseUrl:'http://localhost:8000', loginUrl: '/api/auth/login', providers: { google: { clientId: '....', url: '/api/auth/google' } } }) 向服务器发送会话数据时,这是POST有效负载 { "authorizationDat
Ng2UiAuthModule.forRoot({
baseUrl:'http://localhost:8000',
loginUrl: '/api/auth/login',
providers: {
google: {
clientId: '....',
url: '/api/auth/google'
}
}
})
向服务器发送会话数据时,这是POST有效负载
{
"authorizationData": {
//the same data sent to the auth endpoint
},
"oauthData": {
//the data received from the oauth endpoint
},
"userData": {
//additional data you've provided
}
}
如
然而,Lumen框架中的Socialite需要对象根中的两个字段code
和redirect\u uri
,否则会引发以下错误
{“message”:“客户端错误:POST https:\/\/accounts.google.com\/o\/oauth2\/token
导致400错误请求
响应:\n{\n“error\”:“invalid\u Request\”,\n“error\u description\”:“缺少必需参数:code\”\n}\n,“code”:400,“status\u code”:500}
我在文档中找不到任何东西
我是否缺少一些配置?有人解决了这个问题吗
提前感谢此问题已经很老了,但此解决方案可能会帮助遇到此问题的其他人 以下是我们在流明API方面所做的工作:
// Due to the changes in ng2-ui-auth (Angular) we set the fiels to the right place
if (!$request->has('code'))
$request->request->add(['code' => $request->input('oauthData.code')]);
if (!$request->has('redirect_uri'))
$request->request->add(['redirect_uri' => $request->input('authorizationData.redirect_uri')]);
// Retrieve the redirectUri
$redirectUri = $request->has('redirectUri') ? $request->get('redirectUri') : $request->get('redirect_uri');
// Inits using the google (stateless) driver
$provider = Socialite::with('google');
$provider->redirectUrl($redirectUri);
$provider->stateless();
事实上,使用新的NG2UIAuth(v8+)时,代码和重定向uri发生了变化。因此,在这里,我们只是把它们放在正确的位置(以防它不再改变),我们还确保它与旧版本一起工作。当然,不要忘记keep the stateless(),因为lumen不处理会话