CodeIgniter Forums
Login Question Codeigniter with Google API - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Login Question Codeigniter with Google API (/showthread.php?tid=68106)



Login Question Codeigniter with Google API - wolfgang1983 - 05-25-2017

When a user logins with my google api function and is success full it adds # to the redirected controller url

I don't know how its adding the # hashtag to the redirect url I use vhost


PHP Code:
http://domain.com/usercp# 


Question is there away to stop the hashtag from showing up when user is redirect to there usercp?



PHP Code:
public function google() {
 
   $googleplus_auth $this->googleplus->getAuthenticate();
    
 
   $googleplus_info $this->googleplus->getUserInfo();

 
   $google_data = array(
    
'google_id' => $googleplus_info['id'],
    
'google_name' => $googleplus_info['name'],
    
'google_link' => $googleplus_info['link'],
    
'image' => $googleplus_info['picture'],
    
'email' => $googleplus_info['email'],
    
'firstname' => $googleplus_info['given_name'],
    
'lastname' => $googleplus_info['family_name']
 
   );

 
   $login_google_userid $this->login_model->login_with_google($googleplus_info['id'], $google_data);

 
   $_SESSION['user_id'] = $login_google_userid;

 
   redirect('usercp');




[Image: 3NmPQILJbu5E.png]

PHP Code:
<?php

defined
('BASEPATH') OR exit('No direct script access allowed');

$config['googleplus']['application_name'] = 'Some Name';
$config['googleplus']['client_id'       '********;  // Some id
$config['
googleplus']['client_secret']    = '********'; // Some secret
$config['
googleplus']['redirect_uri']     = 'http://www.mysetdomain.com/account/login/google';
$config['googleplus']['api_key'         '********'// Some api
$config['googleplus']['scopes'          = array(); 




I use this google api from here https://github.com/moemoe89/google-login-ci3


RE: Login Question Codeigniter with Google API - rtenny - 05-26-2017

(05-25-2017, 11:23 PM)wolfgang1983 Wrote: When a user logins with my google api function and is success full it adds # to the redirected controller url

I don't know how its adding the # hashtag to the redirect url I use vhost


PHP Code:
http://domain.com/usercp# 


Question is there away to stop the hashtag from showing up when user is redirect to there usercp?



PHP Code:
public function google() {
 
   $googleplus_auth $this->googleplus->getAuthenticate();
    
 
   $googleplus_info $this->googleplus->getUserInfo();

 
   $google_data = array(
    
'google_id' => $googleplus_info['id'],
    
'google_name' => $googleplus_info['name'],
    
'google_link' => $googleplus_info['link'],
    
'image' => $googleplus_info['picture'],
    
'email' => $googleplus_info['email'],
    
'firstname' => $googleplus_info['given_name'],
    
'lastname' => $googleplus_info['family_name']
 
   );

 
   $login_google_userid $this->login_model->login_with_google($googleplus_info['id'], $google_data);

 
   $_SESSION['user_id'] = $login_google_userid;

 
   redirect('usercp');




I use this google api from here https://github.com/moemoe89/google-login-ci3

I always have a trailing / in the redirect- Not sure, but see that that helps your issue

PHP Code:
redirect('usercp/'); 



RE: Login Question Codeigniter with Google API - wolfgang1983 - 05-26-2017

(05-26-2017, 01:27 AM)rtenny Wrote:
(05-25-2017, 11:23 PM)wolfgang1983 Wrote: When a user logins with my google api function and is success full it adds # to the redirected controller url

I don't know how its adding the # hashtag to the redirect url I use vhost


PHP Code:
http://domain.com/usercp# 


Question is there away to stop the hashtag from showing up when user is redirect to there usercp?



PHP Code:
public function google() {
 
   $googleplus_auth $this->googleplus->getAuthenticate();
    
 
   $googleplus_info $this->googleplus->getUserInfo();

 
   $google_data = array(
    
'google_id' => $googleplus_info['id'],
    
'google_name' => $googleplus_info['name'],
    
'google_link' => $googleplus_info['link'],
    
'image' => $googleplus_info['picture'],
    
'email' => $googleplus_info['email'],
    
'firstname' => $googleplus_info['given_name'],
    
'lastname' => $googleplus_info['family_name']
 
   );

 
   $login_google_userid $this->login_model->login_with_google($googleplus_info['id'], $google_data);

 
   $_SESSION['user_id'] = $login_google_userid;

 
   redirect('usercp');




I use this google api from here https://github.com/moemoe89/google-login-ci3

I always have a trailing / in the redirect- Not sure, but see that that helps your issue

PHP Code:
redirect('usercp/'); 

Just adds # hashtag after /#

Now very strange not sure why adds hashtag when redirect to usercp


RE: Login Question Codeigniter with Google API - InsiteFX - 05-26-2017

He's missing the single ending quote on the below...

PHP Code:
$config['googleplus']['client_id'       '********; 

Not sure if that's the full problem.


RE: Login Question Codeigniter with Google API - Paradinight - 05-26-2017

PHP Code:
<?php

class Test extends MY_Controller
{
    public function 
__construct()
    {
        
parent::__construct();
    }

    public function 
page1() {
        echo 
'<a href="'.base_url('test/page2').'#i_like_cookies">Page 2</a>';
    }
    
    public function 
page2() {
        
redirect('test/page3'); 
    }
    
    public function 
page3() {
        echo 
'look at the url :)';
    }


@wolfgang1983 do you need an explain? Some of you links has # Tongue


RE: Login Question Codeigniter with Google API - wolfgang1983 - 05-26-2017

(05-26-2017, 05:55 AM)InsiteFX Wrote: He's missing the single ending quote on the below...

PHP Code:
$config['googleplus']['client_id'       '********; 

Not sure if that's the full problem.

I put that ******* on here because client id is private. No one else but me is to see it.


RE: Login Question Codeigniter with Google API - wolfgang1983 - 05-26-2017

(05-26-2017, 09:04 AM)Paradinight Wrote:
PHP Code:
<?php

class Test extends MY_Controller
{
 
   public function __construct()
 
   {
 
       parent::__construct();
 
   }

 
   public function page1() {
 
       echo '<a href="'.base_url('test/page2').'#i_like_cookies">Page 2</a>';
 
   }
    
    public function 
page2() {
        
redirect('test/page3'); 
    }
    
    public function 
page3() {
        echo 
'look at the url :)';
    }


@wolfgang1983  do you need an explain? Some of you links has #  Tongue

Its some thing to do with the google api login link once success full it adds # to my http://www.example.com/usercp# my code is fine.


RE: Login Question Codeigniter with Google API - wolfgang1983 - 05-26-2017

(05-26-2017, 05:55 AM)InsiteFX Wrote: He's missing the single ending quote on the below...

PHP Code:
$config['googleplus']['client_id'       '********; 

Not sure if that's the full problem.

I think I need to some how clean url string before I redirect so it removes # not sure how but will look into it.


RE: Login Question Codeigniter with Google API - Paradinight - 05-26-2017

(05-26-2017, 06:24 PM)wolfgang1983 Wrote:
(05-26-2017, 05:55 AM)InsiteFX Wrote: He's missing the single ending quote on the below...

PHP Code:
$config['googleplus']['client_id'       '********; 

Not sure if that's the full problem.

I think I need to some how clean url string before I redirect so it removes # not sure how but will look into it.

You use javascript for event handling. You use the link element with a hash as href?

Try on you link event code
https://api.jquery.com/event.preventdefault/


RE: Login Question Codeigniter with Google API - InsiteFX - 05-27-2017

I understand that, I was just pointing out that you were missing the ending closing quote.