LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
 
Search this Thread
Old 02-27-2014, 08:36 AM   #1
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,431
Blog Entries: 1

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
Simple PHP example of using Google Auth?


Anyone have a good link, to a simple PHP implementation of Google 0Auth-2?

An example site like index.php, sign-in.php, and only-allowed-to-see-this-if-you-are-authenticated.php would be phenomenal.

Thank you.
 
Old 02-27-2014, 08:53 AM   #2
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 403

Rep: Reputation: 113Reputation: 113
Hmm, hard to find what you want... but here's the place to start:

https://code.google.com/p/google-api-php-client/ -- It's full of examples..

This one provides a fairly good example: https://code.google.com/p/google-api...tion/index.php

Basically, the 'only-allowed-to-see-this-if-you-are-authenticated.php' would absolutely need to have at least this:

PHP Code:

require_once '../../src/Google_Client.php';
session_start();

$client = new Google_Client();
$client->setApplicationName("Google Prediction API PHP Starter Application");

//$client->setClientId('insert_your_oauth2_client_id');
//$client->setClientSecret('insert_your_oauth2_client_secret');
// $client->setRedirectUri('insert_your_oauth2_redirect_uri');
// $client->setDeveloperKey('insert_your_developer_key');
// BTW.. These values can be set in a global API config file so you don't need them everytime

if (isset($_SESSION['access_token'])) {
  
$client->setAccessToken($_SESSION['access_token']);
}

if (
$client->getAccessToken()) {
  
$status "Logged In";
  
//Rest of the page?
} else {
  
$status "Logged Out";
  
$authUrl $client->createAuthUrl();
  
//Redirect to auth page


Last edited by Smokey_justme; 02-27-2014 at 08:55 AM.
 
1 members found this post helpful.
Old 02-27-2014, 08:56 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,431
Blog Entries: 1

Original Poster
Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
Thank you for your prompt and informative reply. This is what I was searching for without much luck.

Update:

Here is additional examples: http://code.google.com/p/simple-php-oauth/

Last edited by szboardstretcher; 02-27-2014 at 09:04 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make an online PHP contact / phone book with simple PHP (no database)? Xeratul Programming 23 07-11-2011 12:50 PM
Apache - mod auth external with php kptn3m0 Solaris / OpenSolaris 4 04-27-2011 03:30 PM
Php: Smtp-auth Cram-md5 nathacof Programming 1 02-19-2011 01:04 PM
Simple Email server for FC4 - POP, SMTP (with auth) hansmast Linux - Software 10 05-21-2006 01:46 AM
PHP auth method Davus Programming 4 07-31-2005 04:06 PM


All times are GMT -5. The time now is 12:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration