CodeIgnither OAuth 2.0 database setup for users and access_tokens

Posted by xref on Stack Overflow See other posts from Stack Overflow or by xref
Published on 2012-10-09T21:35:45Z Indexed on 2012/10/09 21:36 UTC
Read the original article Hit count: 207

Filed under:
|
|

Per this question I am using CodeIgniter and OAuth 2 in an attempt to provide SSO for internal users of my webapp, ideally verifying them against their Google Apps account. No registrations or anything, just existing users.

Using the CI oauth2 spark I'm getting back from Google an OAuth token similar to below:

OAuth2_Token_Access Object
 (
   [access_token:protected] => dp83.AHSDj899sDHHD908DHFBDjidkd8989dDHhjjd
   [expires:protected] => 1349816820
   [refresh_token:protected] => 
   [uid:protected] => 
 )

And using that token I can retrieve some user info from Google:

[uid] => 3849450385394595
[nickname] => this_guy
[name] => This Guy
[first_name] => This
[last_name] => Guy
[email] => [email protected]
[location] => 
[image] => 
[description] => 
[urls] => Array
    (
    )

Now to allow the 15 people or so who will be using the webapp currently to log in, do I need to create a users table in the mysql database with their email address as a key? Then compare the email which just came back from the Google OAuth request and see if it exists in my users table?

What about the Google access_token, do I store that now along with the email which already existed in the users table?

Related: How would I go about verifying the user automatically in the future against that access_token so they don't have to go through the whole OAuth approval process with Google again?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about codeigniter