andacata / HybridIgniter

HybridAuth - CodeIgniter integration
139 stars 82 forks source link

redirecting to the wrong endpoint url #13

Closed mozi22 closed 11 years ago

mozi22 commented 11 years ago

Hey I am trying to integrate hybridigniter to my site.I've got this problem where it redirects me to the wrong endpoint url.

http://localhost/php/ci2/?index.php/hauth/endpoint&hauth.start=[provider]&hauth.time=[time]

This is the wrong url. Now I manually changed the url to

http://localhost/php/ci2/index.php/hauth/endpoint/?hauth.start=[provider]&hauth.time=[time]

and it worked.I replaced & with /? and removed ? before index.php.

So i just wanted to ask what settings should I change to make hybridigniter redirect me to this correct url instead of the above one.

andacata commented 11 years ago

Has you changed the default "base_url" config value on config/hybridauthlib.php ?

The value must be '/hauth/endpoint'

mozi22 commented 11 years ago

yes it is set to '/hauth/endpoint'.

andacata commented 11 years ago

Can you log the value for $config['base_url'] inside the lib?

For simplicity, change the function __constuct of libraries/hybridauthlib.php with this one:

function __construct($config = array())
{
    $ci =& get_instance();
    $ci->load->helper('url_helper');

    log_message('info', 'application.libraries.HybridAuthLib.__construct: base_url(pre)="'.$config['base_url'].'"');
    $config['base_url'] = site_url((config_item('index_page') == '' ? SELF : '').$config['base_url']);
    log_message('info', 'application.libraries.HybridAuthLib.__construct: base_url(post)="'.$config['base_url'].'"');

    parent::__construct($config);

    log_message('debug', 'HybridAuthLib Class Initalized');
}

And copy here the results from the log.

mozi22 commented 11 years ago

I was not able to understand the log it was filled with a lot of content. so I just echoed the value in the lib file constructor which you asked me to update above.

I put these lines.

echo $config['base_url']; exit();

and it gave me this url

http://localhost/php/ci2/?index.php/hauth/endpoint.

andacata commented 11 years ago

Are you using the query strings? (Value of $config['enable_query_strings'] inside config/config.php)

mozi22 commented 11 years ago

yes I am using query strings.

andacata commented 11 years ago

For now, HybridIgniter is not supporting query strings, I'm sorry.

I've created a new milestone to make this to work.

Until then, you can configure your full URL to the endpoint inside config/hybridauthlib.php and comment out the line inside libraries/hybridauthlib.php:

//$config['base_url'] = site_url((config_item('index_page') == '' ? SELF : '').$config['base_url']);
mozi22 commented 11 years ago

so if I set $config['enable_query_strings'] to false then it will work fine ?

andacata commented 11 years ago

I hope :)

mozi22 commented 11 years ago

you're right i set it to false it worked but it was giving some other error . Error authenticating user. Can't we do something about the $config['enable_query_strings'] I really want to use this :(

andacata commented 11 years ago

If you need to use query strings, make the modificacions indicated in my previous comment:

Configure your full endpoint URL inside config/hybridauthlib.php:

'base_url' => 'http://localhost/php/ci2/index.php/hauth/endpoint',

Comment out the line inside libraries/hybridauthlib.php:

//$config['base_url'] = site_url((config_item('index_page') == '' ? SELF : '').$config['base_url']);
mozi22 commented 11 years ago

ok that worked fine thnx. Just one last thing. Can you tell me why it is giving Error authenticating user ?

andacata commented 11 years ago

Possibly it's caused by a misconfiguration of the credentials for the social provider you are using.

mozi22 commented 11 years ago

its working thanks alot .

andacata commented 11 years ago

You're welcome.

andacata commented 11 years ago

Ups, closed by error.

mozi22 commented 11 years ago

hey can you help me plz I've got stuck again :)

its giving me "Hybriauth configuration error" and it is giving me the error at this line.

$this->load->library('HybridAuthLib');
mozi22 commented 11 years ago

I think it was due to the log folder. I didn't uploaded the log folder as I uploaded it. It started working fine

mozi22 commented 11 years ago

@andacata I am trying to login but it keeps saying "User profile request failed. Most likely the user is not connected to the provider and he should to authenticate again."

I tried redirecting the script but it generates a loop. Why is this happening and it works fine sometimes but sometimes it keeps giving this error.

andacata commented 11 years ago

If you are having connection/login problems, you need to test your configuration with a simple HybridAuth installation (without CodeIgniter) to isolate the problem.