我有一个奇怪的问题,使用Laravel Socialite通过Google API登录用户.
一切配置看似正常和普通,但我不断收到错误Missing required parameter: client_id.不仅如此,有时我再次尝试,Missing required parameter: redirect_uri尽管已经提供了所有这些参数,但错误仍然存在.
这就是它的设置方式:
service.php
'google' => [
'client_id' => 'xxxxxxxxxx-x98asxxxx913ofk5tqvgq7lqfpgdi5u2.apps.googleusercontent.com',
'client_secret' => 'mklOWJFhpbCzTKxxxx-xxxx',
'redirect' => 'http://myapp.com/auth/google/callback'
],
Run Code Online (Sandbox Code Playgroud)
routes.php文件
Route::get('/auth/{social_channel}', 'Auth\AuthController@redirect_to_provider');
Route::get('/auth/{social_channel}/callback', 'Auth\AuthController@handle_provider_callback');
Run Code Online (Sandbox Code Playgroud)
AuthController.php
/**
* Redirect the user to the Google authentication page.
*
* @return Response
*/
public function redirect_to_provider($social_channel)
{
return Socialite::driver($social_channel)->redirect();
}
/**
* Obtain the user information from GitHub.
*
* @return Response
*/
public function handle_provider_callback($social_channel, SocialAccountService $service)
{
$user = $service->create_or_get_user($social_channel, Socialite::driver($social_channel)->user()); …Run Code Online (Sandbox Code Playgroud) 我在angularjs应用程序中设置cookie时一直遇到麻烦.情况是我想在站点范围内设置一个cookie,但我不知道如何使用angular js default $ cookies对象设置cookie的所有参数.
例如,通常在Javascript中我会写这个
var exp = new Date();
exp.setTime(exp.getTime()+(24*60*60*1000)); // expires after a day
document.cookie = "myCookies=yes;expires="+exp.toGMTString()+ ";domain=.example.com;path=/";
Run Code Online (Sandbox Code Playgroud)
但由于DOM对象无法轻松加载到我的应用程序中,因此我必须使用$ cookies(angular-cookies.js).新代码是:
angular.module('MyApp')
.controller('MyCtrl', function ($scope, $filter, Slug,PUBLIC_ROUTES, $cookies) {
var myCookies = $cookies['mycookies'];
if (typeof myCookies == 'undefined' || typeof myCookies == undefined) {
$cookies['mycookies'] = "yes";
}
});
Run Code Online (Sandbox Code Playgroud)
但我无法设置到期日期,路径和域名,因为$ cookies不可用.
我该怎么办?