How to use open id as login system
I want to try to use open id as login system on the site that I am going to make. I've check out this site, and I'm not pretty sure how this all works and how to make it work. http://remysharp.com/2007/12/21/how-to-integrate-openid-as-your-login-system/
What is clear right now is that open id uses urls instead of passwords. Can you give me some links to help me get started with this, Do I need to know advanced php to make this work for me. I only know the basics of php.
Thanks to some other comment on Stackoverflow.com I came to learn about LightOpenId. It is really easy to use.
The example code just works(without any configuration):
<?php
require 'openid.php';
try {
$openid = new LightOpenID;
if(!$openid->mode) {
if(isset($_POST['openid_identifier'])) {
$openid->identity = $_POST['openid_identifier'];
header('Location: ' . $openid->authUrl());
}
?>
<form action="" method="post">
OpenID: <input type="text" name="openid_identifier" /> <button>Submit</button>
</form>
<?php
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
Using google as openid provider.
<?php
# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
require 'openid.php';
try {
$openid = new LightOpenID;
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'https://www.google.com/accounts/o8/id';
header('Location: ' . $openid->authUrl());
}
?>
<form action="?login" method="post">
<button>Login with Google</button>
</form>
<?php
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
You can use the PHP OpenID library here or for PHP 4 here