Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>As original author of this answer, I want to note that I regard it as <strong>OUTDATED</strong>. Since most providers decided to exclusively implement Oauth instead of Openid. Newer Openid services will also likely use openid connect, which is based on oauth. There are good libraries like for example: <a href="https://github.com/hybridauth/hybridauth" rel="nofollow noreferrer">https://github.com/hybridauth/hybridauth</a></p> </blockquote> <p>After the discussion of the already existing answer i sum up:</p> <p>Almost every major provider is an openid provider / endpoint including Google, Yahoo, Aol.</p> <p>Some of them requrie the user to specify the username to construct the openid endpoint. Some of them (the ones mentioned above) do have discovery urls, where the user id is automatically returned so that the user only has to click. (i would be glad if someone could explain the technical background)</p> <p>However the only pain in the ass is Facebook, because they have their Facebook connect where they use an adapted version of OAuth for authentication.</p> <p>Now what I did for my project is to set up an openid provider that authenticates the user with the credentials of my facebook Application - so the user gets connected to my application - and returns a user id that looks like:</p> <pre><code>http://my-facebook-openid-proxy-subdomain.mydomain.com/?id=facebook-user-id </code></pre> <p>I also configured it to fetch email adress and name and return it as AX attributes.</p> <p>So my website just has to implement opend id and i am fine :)</p> <p>I build it upon the classes you can find here: <a href="http://gitorious.org/lightopenid" rel="nofollow noreferrer">http://gitorious.org/lightopenid</a></p> <p>In my index.php file i just call it like this:</p> <pre><code>&lt;?php require 'LightOpenIDProvider.php'; require 'FacebookProvider.php'; $op = new FacebookProvider; $op-&gt;appid = 148906418456860; // your facebook app id $op-&gt;secret = 'mysecret'; // your facebook app secret $op-&gt;baseurl = 'http://fbopenid.2xfun.com'; // needs to be allowed by facebook $op-&gt;server(); ?&gt; </code></pre> <p>and the source code of FacebookProvider.php follows:</p> <pre><code>&lt;?php class FacebookProvider extends LightOpenIDProvider { public $appid = ""; public $appsecret = ""; public $baseurl = ""; // i have really no idea what this is for. just copied it from the example. public $select_id = true; function __construct() { $this-&gt;baseurl = rtrim($this-&gt;baseurl,'/'); // no trailing slash as it will be concatenated with // request uri wich has leading slash parent::__construct(); # If we use select_id, we must disable it for identity pages, # so that an RP can discover it and get proper data (i.e. without select_id) if(isset($_GET['id'])) { // i have really no idea what happens here. works with or without! just copied it from the example. $this-&gt;select_id = false; } } function setup($identity, $realm, $assoc_handle, $attributes) { // here we should check the requested attributes and adjust the scope param accordingly // for now i just hardcoded email $attributes = base64_encode(serialize($attributes)); $url = "https://graph.facebook.com/oauth/authorize?client_id=".$this-&gt;appid."&amp;redirect_uri="; $redirecturl = urlencode($this-&gt;baseurl.$_SERVER['REQUEST_URI'].'&amp;attributes='.$attributes); $url .= $redirecturl; $url .= "&amp;display=popup"; $url .= "&amp;scope=email"; header("Location: $url"); exit(); } function checkid($realm, &amp;$attributes) { // try authenticating $code = isset($_GET["code"]) ? $_GET["code"] : false; if(!$code) { // user has not authenticated yet, lets return false so setup redirects him to facebook return false; } // we have the code parameter set so it looks like the user authenticated $url = "https://graph.facebook.com/oauth/access_token?client_id=148906418456860&amp;redirect_uri="; $redirecturl = ($this-&gt;baseurl.$_SERVER['REQUEST_URI']); $redirecturl = strstr($redirecturl, '&amp;code', true); $redirecturl = urlencode($redirecturl); $url .= $redirecturl; $url .= "&amp;client_secret=".$this-&gt;secret; $url .= "&amp;code=".$code; $data = $this-&gt;get_data($url); parse_str($data,$data); $token = $data['access_token']; $data = $this-&gt;get_data('https://graph.facebook.com/me?access_token='.urlencode($token)); $data = json_decode($data); $id = $data-&gt;id; $email = $data-&gt;email; $attribute_map = array( 'namePerson/friendly' =&gt; 'name', // we should parse the facebook link to get the nickname 'contact/email' =&gt; 'email', ); if($id &gt; 0) { $requested_attributes = unserialize(base64_decode($_GET["attributes"])); // lets be nice and return everything we can $requested_attributes = array_merge($requested_attributes['required'],$requested_attributes['optional']); $attributes = array(); foreach($requested_attributes as $requsted_attribute) { if(!isset($data-&gt;{$attribute_map[$requsted_attribute]})) { continue; // unknown attribute } $attributes[$requsted_attribute] = $data-&gt;{$attribute_map[$requsted_attribute]}; } // yeah authenticated! return $this-&gt;serverLocation . '?id=' . $id ; } die('login failed'); // die so we dont retry bouncing back to facebook return false; } function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } } </code></pre> <p>Its just a first working version (quick and dirty) Some dynamic stuff is hardcoded to my needs. It should show how and that it can be done. I am happy if someone picks up and improves it or re writes it or whatever :)</p> <p>Well i consider this question answered </p> <p>but I add a bounty just to get discussion. I would like to know what you think of my solution.</p> <p>I will award the bounty to the best answer/comment beside this one.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload