Scope email issue on google login codeigniter
I have created google login using CodeIgniter which is working fine it takes me on login page when I click on Google image
after filling up all details when I click on next button then it takes me out from google login to my website and URL look likes
https://example.com/google_login?code=4/lQDGQ6sJog3ZrLKGJtn-VVD3rbzgJl16jMLUrk6wzBIbsu-F6mjlLuPOepeobDLmFYqQL25jo4iAgI9ZnVKTSVY&scope=email%20profile%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
which show me 404 error but if I remove &scope=email%20profile%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
from URL then it shows me all information of clients.
controller.
public function login()
{
$userData = array();
if($this->facebook->is_authenticated()){
$fbUserProfile = $this->facebook->request('get', '/me?fields=id,first_name,last_name,email,picture');
$userData['oauth_provider'] = 'facebook';
$userData['oauth_uid'] = $fbUserProfile['id'];
$userData['name'] = $fbUserProfile['first_name']." ".$fbUserProfile['last_name'];
$userData['email'] = $fbUserProfile['email'];
$userData['user_image'] = $fbUserProfile['picture']['data']['url'];
$userID = $this->user->checkUser($userData);
if(!empty($userID))
{
$data['userData'] = $userData;
$this->session->set_userdata('userData',$userData);
}
else
{
$data['userData'] = array();
}
$data['logoutURL'] = $this->facebook->logout_url();
}
else
{
$data['authURL'] = $this->facebook->login_url();
}
$data['loginURL'] = $this->google->loginURL();
$this->load->view('login',$data);
}
public function google_login()
{
if($this->session->userdata('loggedIn') == true){
redirect('profile');
}
if(isset($_GET['code'])){
if($this->google->getAuthenticate()){
$gpInfo = $this->google->getUserInfo();
$userData['oauth_provider'] = 'google';
$userData['oauth_uid'] = $gpInfo['id'];
$userData['name'] = $gpInfo['given_name'].' '.$gpInfo['family_name'];
$userData['email'] = $gpInfo['email'];
$userData['user_image'] = !empty($gpInfo['picture'])?$gpInfo['picture']:'';
$userID = $this->Google_user->checkUser($userData);
$this->session->set_userdata('loggedIn', true);
$this->session->set_userdata('userData', $userData);
redirect('profile');
}
}
}
view:login.php
<a href="<?php echo $loginURL; ?>" class="google btn-block"><i class="fa fa-google-plus"></i></a>
config/route.php
$route['google_login'] = "welcome/google_login";
config/google.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
$config['google']['client_id'] = '**********************************************';
$config['google']['client_secret'] = '************************';
$config['google']['redirect_uri'] = 'https://example.com/google_login';
$config['google']['application_name'] = 'Login to Example';
$config['google']['api_key'] = '';
$config['google']['scopes'] = array();
So, How can I fix this issue? Please help me.
Thank You
codeigniter google-login
add a comment |
I have created google login using CodeIgniter which is working fine it takes me on login page when I click on Google image
after filling up all details when I click on next button then it takes me out from google login to my website and URL look likes
https://example.com/google_login?code=4/lQDGQ6sJog3ZrLKGJtn-VVD3rbzgJl16jMLUrk6wzBIbsu-F6mjlLuPOepeobDLmFYqQL25jo4iAgI9ZnVKTSVY&scope=email%20profile%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
which show me 404 error but if I remove &scope=email%20profile%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
from URL then it shows me all information of clients.
controller.
public function login()
{
$userData = array();
if($this->facebook->is_authenticated()){
$fbUserProfile = $this->facebook->request('get', '/me?fields=id,first_name,last_name,email,picture');
$userData['oauth_provider'] = 'facebook';
$userData['oauth_uid'] = $fbUserProfile['id'];
$userData['name'] = $fbUserProfile['first_name']." ".$fbUserProfile['last_name'];
$userData['email'] = $fbUserProfile['email'];
$userData['user_image'] = $fbUserProfile['picture']['data']['url'];
$userID = $this->user->checkUser($userData);
if(!empty($userID))
{
$data['userData'] = $userData;
$this->session->set_userdata('userData',$userData);
}
else
{
$data['userData'] = array();
}
$data['logoutURL'] = $this->facebook->logout_url();
}
else
{
$data['authURL'] = $this->facebook->login_url();
}
$data['loginURL'] = $this->google->loginURL();
$this->load->view('login',$data);
}
public function google_login()
{
if($this->session->userdata('loggedIn') == true){
redirect('profile');
}
if(isset($_GET['code'])){
if($this->google->getAuthenticate()){
$gpInfo = $this->google->getUserInfo();
$userData['oauth_provider'] = 'google';
$userData['oauth_uid'] = $gpInfo['id'];
$userData['name'] = $gpInfo['given_name'].' '.$gpInfo['family_name'];
$userData['email'] = $gpInfo['email'];
$userData['user_image'] = !empty($gpInfo['picture'])?$gpInfo['picture']:'';
$userID = $this->Google_user->checkUser($userData);
$this->session->set_userdata('loggedIn', true);
$this->session->set_userdata('userData', $userData);
redirect('profile');
}
}
}
view:login.php
<a href="<?php echo $loginURL; ?>" class="google btn-block"><i class="fa fa-google-plus"></i></a>
config/route.php
$route['google_login'] = "welcome/google_login";
config/google.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
$config['google']['client_id'] = '**********************************************';
$config['google']['client_secret'] = '************************';
$config['google']['redirect_uri'] = 'https://example.com/google_login';
$config['google']['application_name'] = 'Login to Example';
$config['google']['api_key'] = '';
$config['google']['scopes'] = array();
So, How can I fix this issue? Please help me.
Thank You
codeigniter google-login
you seem to be missing a route to catch the response from google. Can you show your routes file?
– killstreet
Nov 14 '18 at 13:06
@killstreet please look at once in my edit question
– Bruce
Nov 14 '18 at 13:19
1
In your return URL u got'&scope=email%20profile%20https://' the / after https: is breaking your url.
– killstreet
Nov 14 '18 at 13:36
So, how can I fix this @killstreet
– Bruce
Nov 15 '18 at 4:40
Honestly I wouldn't know. If this is what google redirects you to then it seems to be a problem at google's end since this isn't a URL friendly code. I noticed that the problem actually comes earlier in the URL.
– killstreet
Nov 15 '18 at 9:59
add a comment |
I have created google login using CodeIgniter which is working fine it takes me on login page when I click on Google image
after filling up all details when I click on next button then it takes me out from google login to my website and URL look likes
https://example.com/google_login?code=4/lQDGQ6sJog3ZrLKGJtn-VVD3rbzgJl16jMLUrk6wzBIbsu-F6mjlLuPOepeobDLmFYqQL25jo4iAgI9ZnVKTSVY&scope=email%20profile%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
which show me 404 error but if I remove &scope=email%20profile%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
from URL then it shows me all information of clients.
controller.
public function login()
{
$userData = array();
if($this->facebook->is_authenticated()){
$fbUserProfile = $this->facebook->request('get', '/me?fields=id,first_name,last_name,email,picture');
$userData['oauth_provider'] = 'facebook';
$userData['oauth_uid'] = $fbUserProfile['id'];
$userData['name'] = $fbUserProfile['first_name']." ".$fbUserProfile['last_name'];
$userData['email'] = $fbUserProfile['email'];
$userData['user_image'] = $fbUserProfile['picture']['data']['url'];
$userID = $this->user->checkUser($userData);
if(!empty($userID))
{
$data['userData'] = $userData;
$this->session->set_userdata('userData',$userData);
}
else
{
$data['userData'] = array();
}
$data['logoutURL'] = $this->facebook->logout_url();
}
else
{
$data['authURL'] = $this->facebook->login_url();
}
$data['loginURL'] = $this->google->loginURL();
$this->load->view('login',$data);
}
public function google_login()
{
if($this->session->userdata('loggedIn') == true){
redirect('profile');
}
if(isset($_GET['code'])){
if($this->google->getAuthenticate()){
$gpInfo = $this->google->getUserInfo();
$userData['oauth_provider'] = 'google';
$userData['oauth_uid'] = $gpInfo['id'];
$userData['name'] = $gpInfo['given_name'].' '.$gpInfo['family_name'];
$userData['email'] = $gpInfo['email'];
$userData['user_image'] = !empty($gpInfo['picture'])?$gpInfo['picture']:'';
$userID = $this->Google_user->checkUser($userData);
$this->session->set_userdata('loggedIn', true);
$this->session->set_userdata('userData', $userData);
redirect('profile');
}
}
}
view:login.php
<a href="<?php echo $loginURL; ?>" class="google btn-block"><i class="fa fa-google-plus"></i></a>
config/route.php
$route['google_login'] = "welcome/google_login";
config/google.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
$config['google']['client_id'] = '**********************************************';
$config['google']['client_secret'] = '************************';
$config['google']['redirect_uri'] = 'https://example.com/google_login';
$config['google']['application_name'] = 'Login to Example';
$config['google']['api_key'] = '';
$config['google']['scopes'] = array();
So, How can I fix this issue? Please help me.
Thank You
codeigniter google-login
I have created google login using CodeIgniter which is working fine it takes me on login page when I click on Google image
after filling up all details when I click on next button then it takes me out from google login to my website and URL look likes
https://example.com/google_login?code=4/lQDGQ6sJog3ZrLKGJtn-VVD3rbzgJl16jMLUrk6wzBIbsu-F6mjlLuPOepeobDLmFYqQL25jo4iAgI9ZnVKTSVY&scope=email%20profile%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
which show me 404 error but if I remove &scope=email%20profile%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
from URL then it shows me all information of clients.
controller.
public function login()
{
$userData = array();
if($this->facebook->is_authenticated()){
$fbUserProfile = $this->facebook->request('get', '/me?fields=id,first_name,last_name,email,picture');
$userData['oauth_provider'] = 'facebook';
$userData['oauth_uid'] = $fbUserProfile['id'];
$userData['name'] = $fbUserProfile['first_name']." ".$fbUserProfile['last_name'];
$userData['email'] = $fbUserProfile['email'];
$userData['user_image'] = $fbUserProfile['picture']['data']['url'];
$userID = $this->user->checkUser($userData);
if(!empty($userID))
{
$data['userData'] = $userData;
$this->session->set_userdata('userData',$userData);
}
else
{
$data['userData'] = array();
}
$data['logoutURL'] = $this->facebook->logout_url();
}
else
{
$data['authURL'] = $this->facebook->login_url();
}
$data['loginURL'] = $this->google->loginURL();
$this->load->view('login',$data);
}
public function google_login()
{
if($this->session->userdata('loggedIn') == true){
redirect('profile');
}
if(isset($_GET['code'])){
if($this->google->getAuthenticate()){
$gpInfo = $this->google->getUserInfo();
$userData['oauth_provider'] = 'google';
$userData['oauth_uid'] = $gpInfo['id'];
$userData['name'] = $gpInfo['given_name'].' '.$gpInfo['family_name'];
$userData['email'] = $gpInfo['email'];
$userData['user_image'] = !empty($gpInfo['picture'])?$gpInfo['picture']:'';
$userID = $this->Google_user->checkUser($userData);
$this->session->set_userdata('loggedIn', true);
$this->session->set_userdata('userData', $userData);
redirect('profile');
}
}
}
view:login.php
<a href="<?php echo $loginURL; ?>" class="google btn-block"><i class="fa fa-google-plus"></i></a>
config/route.php
$route['google_login'] = "welcome/google_login";
config/google.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
$config['google']['client_id'] = '**********************************************';
$config['google']['client_secret'] = '************************';
$config['google']['redirect_uri'] = 'https://example.com/google_login';
$config['google']['application_name'] = 'Login to Example';
$config['google']['api_key'] = '';
$config['google']['scopes'] = array();
So, How can I fix this issue? Please help me.
Thank You
codeigniter google-login
codeigniter google-login
edited Nov 14 '18 at 13:19
Bruce
asked Nov 14 '18 at 12:39
BruceBruce
235
235
you seem to be missing a route to catch the response from google. Can you show your routes file?
– killstreet
Nov 14 '18 at 13:06
@killstreet please look at once in my edit question
– Bruce
Nov 14 '18 at 13:19
1
In your return URL u got'&scope=email%20profile%20https://' the / after https: is breaking your url.
– killstreet
Nov 14 '18 at 13:36
So, how can I fix this @killstreet
– Bruce
Nov 15 '18 at 4:40
Honestly I wouldn't know. If this is what google redirects you to then it seems to be a problem at google's end since this isn't a URL friendly code. I noticed that the problem actually comes earlier in the URL.
– killstreet
Nov 15 '18 at 9:59
add a comment |
you seem to be missing a route to catch the response from google. Can you show your routes file?
– killstreet
Nov 14 '18 at 13:06
@killstreet please look at once in my edit question
– Bruce
Nov 14 '18 at 13:19
1
In your return URL u got'&scope=email%20profile%20https://' the / after https: is breaking your url.
– killstreet
Nov 14 '18 at 13:36
So, how can I fix this @killstreet
– Bruce
Nov 15 '18 at 4:40
Honestly I wouldn't know. If this is what google redirects you to then it seems to be a problem at google's end since this isn't a URL friendly code. I noticed that the problem actually comes earlier in the URL.
– killstreet
Nov 15 '18 at 9:59
you seem to be missing a route to catch the response from google. Can you show your routes file?
– killstreet
Nov 14 '18 at 13:06
you seem to be missing a route to catch the response from google. Can you show your routes file?
– killstreet
Nov 14 '18 at 13:06
@killstreet please look at once in my edit question
– Bruce
Nov 14 '18 at 13:19
@killstreet please look at once in my edit question
– Bruce
Nov 14 '18 at 13:19
1
1
In your return URL u got'&scope=email%20profile%20https://' the / after https: is breaking your url.
– killstreet
Nov 14 '18 at 13:36
In your return URL u got'&scope=email%20profile%20https://' the / after https: is breaking your url.
– killstreet
Nov 14 '18 at 13:36
So, how can I fix this @killstreet
– Bruce
Nov 15 '18 at 4:40
So, how can I fix this @killstreet
– Bruce
Nov 15 '18 at 4:40
Honestly I wouldn't know. If this is what google redirects you to then it seems to be a problem at google's end since this isn't a URL friendly code. I noticed that the problem actually comes earlier in the URL.
– killstreet
Nov 15 '18 at 9:59
Honestly I wouldn't know. If this is what google redirects you to then it seems to be a problem at google's end since this isn't a URL friendly code. I noticed that the problem actually comes earlier in the URL.
– killstreet
Nov 15 '18 at 9:59
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300464%2fscope-email-issue-on-google-login-codeigniter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300464%2fscope-email-issue-on-google-login-codeigniter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you seem to be missing a route to catch the response from google. Can you show your routes file?
– killstreet
Nov 14 '18 at 13:06
@killstreet please look at once in my edit question
– Bruce
Nov 14 '18 at 13:19
1
In your return URL u got'&scope=email%20profile%20https://' the / after https: is breaking your url.
– killstreet
Nov 14 '18 at 13:36
So, how can I fix this @killstreet
– Bruce
Nov 15 '18 at 4:40
Honestly I wouldn't know. If this is what google redirects you to then it seems to be a problem at google's end since this isn't a URL friendly code. I noticed that the problem actually comes earlier in the URL.
– killstreet
Nov 15 '18 at 9:59