Hi I am using the artdarek oauth for google login in laravel.
I have written the route like the following: Route::get('usersgoogle','logingoogleController@loginwithGoogle');
I am using the same code shown in the oauth documentaion https://github.com/artdarek/oauth-4-laravel
(the example for google consumer).
My controller:
class logingoogleController extends BaseController {
public function loginWithGoogle() {
// get data from input
$code = Input::get( 'code' );
// get google service
$googleService = OAuth::consumer( 'Google' );
//echo $googleService;
// check if code is valid
// if code is provided get user data and sign in
if ( !empty( $code ) ) {
// This was a callback request from google, get the token
$token = $googleService->requestAccessToken( $code );
// Send a request with it
$result = json_decode( $googleService->request( 'https://www.googleapis.com/oauth2/v1/userinfo' ), true );
$message = 'Your unique Google user id is: ' . $result['id'] . ' and your name is ' . $result['name'];
echo $message. "<br/>";
//Var_dump
//display whole array().
dd($result);
}
// if not ask for permission first
else {
// get googleService authorization
$url = $googleService->getAuthorizationUri();
// return to google login url
return Redirect::to( (string)$url );
//echo "Hi";
}
}
}
Now in the google developers I have created a project,created a client id and have specified the redirect uri like the following: http://domainname.com/usersgoogle I have tried with http://domainname.com/usersgoogle/ -'/' at the last but every time its showing me redirect_uri_mismatch error. Can any one tell me what is the right way to do it? what I am doing wrong here?
My google console is like the following:

Please help. Thanks in advanced...