|
|
 dhaivat naik - 2017-01-24 10:39:27
Great Package, Worth it who so ever wants to deal with oAuth. I have used it in past for Google, Twitter, Instagram. Great fan of all classes by Manuel Lemos.
Facing problems when Trying it for RightSignature mysqli offline access and login.
When i try with the file (login_with_rightsignature.php) provided with the package, it works. But When i try with mysqli_login_with_rightsignature.php
it give me an error,
Error: the session to store the access token was not found
I have made sure that i follow each step correctly, and have made necessary changes looking from mysqli_login_with_rightsignature.php and created mysqli_login_with_rightsignature.php But i guess something is incorrect. I tried debuging also but din't succeed
require('http.php');
require('oauth_client.php');
require('database_oauth_client.php');
require('mysqli_oauth_client.php');
$client = new mysqli_oauth_client_class;
$client->database = array(
'host'=>'localhost',
'user'=>'root',
'password'=>'',
'name'=>'oauth_rightsignature',
'port'=>0,
'socket'=>'/var/lib/mysql/mysql.sock'
);
$client->server = 'RightSignature';
$client->offline = true;
$client->debug = true;
$client->debug_http = true;
$client->redirect_uri = 'http://'.$_SERVER['HTTP_HOST'].
dirname(strtok($_SERVER['REQUEST_URI'],'?')).'/mysqli_login_with_rightsignature.php';
$client->client_id = 'MY_CLIENT_ID'; $application_line = __LINE__;
$client->client_secret = 'MY_CLIENT_SECRET';
if(strlen($client->client_id) == 0
|| strlen($client->client_secret) == 0)
die('Please go to RightSignature new application page '.
'https://rightsignature.com/oauth_clients/new , '.
'create an application, and in the line '.$application_line.
' set the client_id to oAuth Key and client_secret with oAuth Secret.');
if(($success = $client->Initialize()))
{
if(($success = $client->Process()))
{
if(strlen($client->authorization_error))
{
$client->error = $client->authorization_error;
$success = false;
}
elseif(strlen($client->access_token))
{
$success = $client->CallAPI(
'https://rightsignature.com/api/users/user_details.json',
'GET', array(), array('FailOnAccessError'=>true), $user);
if($success)
$success = $client->SetUser(1);
}
}
$success = $client->Finalize($success);
}
if($client->exit)
exit;
if($success)
{
}
else
{
<pre>Error: <?php echo HtmlSpecialChars($client->error); ?></pre>
}
Manuel Lemos if you can shed some lights on this it will be helpful. If required i can provide my client_id & client_secret
 dhaivat naik - 2017-01-24 11:19:35 - In reply to message 1 from dhaivat naik
I take my words back, Script is all good, Only issue was that the table structure has 'server' field as CHAR (12) Because of that the value 'RightSignature' was not getting saved in it, And so the access_token was not working.
DROP TABLE IF EXISTS `oauth_session`;
CREATE TABLE `oauth_session` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`session` char(32) NOT NULL DEFAULT '',
`state` char(32) NOT NULL DEFAULT '',
`access_token` mediumtext NOT NULL,
`expiry` datetime DEFAULT NULL,
`type` char(12) NOT NULL DEFAULT '',
`server` char(12) NOT NULL DEFAULT '',
`creation` datetime NOT NULL DEFAULT '2000-01-01 00:00:00',
`access_token_secret` mediumtext NOT NULL,
`authorized` char(1) DEFAULT NULL,
`user` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `social_oauth_session_index` (`session`,`server`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Once again thanks for the wonderful plugin.
 Manuel Lemos - 2017-01-24 11:41:07 - In reply to message 2 from dhaivat naik
I increased the server field length to accomodate for these cases. Thanks for reporting.
|