PHP Classes

Oauth access token into database

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  Improving the Protect...  >  All threads  >  Oauth access token into database  >  (Un) Subscribe thread alerts  
Subject:Oauth access token into database
Summary:saving the access token and reusing it without asking for login
Messages:46
Author:Prabhulal Ramesh
Date:2014-11-20 12:59:04
 
  1 - 10   11 - 20   21 - 30   31 - 40   41 - 46  

  21. Re: Oauth access token into database   Reply   Report abuse  
Picture of Prabhulal Ramesh Prabhulal Ramesh - 2014-11-21 07:17:59 - In reply to message 19 from Manuel Lemos
Lemos , I have some doubts in using some functions which i think it may help me.


like

GetUserSession($user, &$oauth_session)

GetOAuthSession($session, $server, &$oauth_session)


is the paramerter &$oauth_session mandatory for calling the function , ?? since i don have a $session , when using offline .

can u help he with these ....

i am getting error when using MYSQL ...
how to use sqli using query() , i am still new to this sqli ,, cant figure out.


  22. Re: Oauth access token into database   Reply   Report abuse  
Picture of Prabhulal Ramesh Prabhulal Ramesh - 2014-11-21 07:20:29 - In reply to message 14 from Justin
Justin and lemos

where can check for user exist already and fetch his data here ....

in this part of code


# START THE CALL
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))
{
if($data['method'] === 'POST' || $data['method'] === 'PUT') {
if(!array_key_exists('RequestContentType', $data)) {
$data['options']['RequestContentType'] = 'application/json';
}
}
$success = $client->CallAPI($urlToCall, $method, $params, $options, $call);
if($success)
$success = $client->SetUser($userId); # <<< HERE IS WHERE THE DATABASE WILL BE SET.
}
}
$success = $client->Finalize($success);
}

  23. Re: Oauth access token into database   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-21 09:31:28 - In reply to message 20 from Prabhulal Ramesh
To obtain a token first, you need to have a page for that.

Then for accessing the API offline, it is a script that may be run from the command line with PHP CLI as the user no longer needs to be present.

  24. Re: Oauth access token into database   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-21 09:35:35 - In reply to message 21 from Prabhulal Ramesh
If you are using the mysqli_oauth_client class, you should not be accessing those functions. Those are used only internally.

  25. Re: Oauth access token into database   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-21 09:37:31 - In reply to message 23 from Manuel Lemos
As explained above, you need to query your own users database table to check if the user exists.

The OAuth classes do not do that for you because your database users table can be in many ways. It could be called users or something else, it may have fields with any names you like, so it is up to you to do the integration.

  26. Re: Oauth access token into database   Reply   Report abuse  
Picture of Prabhulal Ramesh Prabhulal Ramesh - 2014-11-21 11:36:01 - In reply to message 25 from Manuel Lemos
CAn u tell me waht is the function this line

if($client->exit)
exit;

??? beacuse when i am using in my inappbrowser .... i get my app closed and gets crashed when i click done button..


is there a possiblity to close the window as soon as the login is successful and pass the success value from browser to my app which is a phonegap app using javscript and html5 ????

  27. Re: Oauth access token into database   Reply   Report abuse  
Picture of Prabhulal Ramesh Prabhulal Ramesh - 2014-11-21 13:16:19 - In reply to message 25 from Manuel Lemos
how to pass a dynamic value before sending for a linkedin authorisation


can i use $client->myvariable = user_id_from app


is this correct will this be store for further use i-e after logging in

i am just able to insert static id , unable to insert dynamically because the browser forgets it.

  28. Re: Oauth access token into database   Reply   Report abuse  
Picture of Justin Justin - 2014-11-21 16:32:34 - In reply to message 27 from Prabhulal Ramesh
As for storing, I suggest using a different table to store that data. Create a new table for "users" and have a field, "beforeSessionClose" or something.

Not the most secure option, you could try cookies, a flat database file perhaps, something of that nature so you don't rely on the browser as much.

As for 'closing' the app 'after' logging in, that would be based off of Javascript, seeing as it is a mobile app browser, at least that would be my suggestion.

  29. Re: Oauth access token into database   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-22 02:54:57 - In reply to message 26 from Prabhulal Ramesh
In the first step of OAuth authorization, the class redirects the user to the OAuth server page. So you should not output anything to the browser. That is why it is exiting the script.

In general you should perform the authorize the users in the same window of your login button.

Some sites try to open an new window but that is a bad idea because many times browsers are configured to block popup windows, and the users do not understand why nothing appears.

  30. Re: Oauth access token into database   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-22 02:58:36 - In reply to message 27 from Prabhulal Ramesh
I think you can pass the variable value in the redirect_uri URL that you pass to the class.

 
  1 - 10   11 - 20   21 - 30   31 - 40   41 - 46