1

I'd like to make an OAuth implementation for my site. Not one where I allow users to connect to FB, Twitter, but rather one which connects users or their apps to my site.

There are many good reads of how to do this, but less code demonstrating an actual example. The code bases I've found while impressive are overwhelming.

Might someone point me to a simple PHP script which implements OAuth? I realize there is a database component but assume that part can be described in words, though I'm using MySQL if there might be companion code for that.

Manikandan C
  • 668
  • 1
  • 9
  • 22
tim peterson
  • 23,653
  • 59
  • 177
  • 299

1 Answers1

2

Google is your friend:

http://www.sitepoint.com/creating-a-php-oauth-server/

Please don't use stack to search stuff that you can find yourself by using google.

For completeness sake taken from http://oauth.net/code/.

  • There is an extension to PHP that supports OAuth. It was written by John Jawed. An example can be found here and a walkthrough is also available. This pecl package is considered the de facto standard by Rasmus Lerdorf.
  • Manuel Lemos has written a PHP OAuth class that abstracts OAuth 1.0a and OAuth 2.0 in the same class. It provides built-in support to several popular OAuth servers, so you do not have to spend time configuring the respective end point URLs. It supports every other OAuth server through specific configuration variables, including some meant to workaround OAuth implementation glitches that some servers have. Documentation and practical examples come with the class package.
  • Andy Smith has written a basic PHP library for OAuth.
  • Cal Henderson has contributed a simple OAuth library that primarily handles signing.
  • HTTP_OAuth is a PEAR package developed by Jeff Hodsdon and Bill Shupp (Digg). You can try it out using this tool.
  • There is now an OAuth component for CakePHP.
  • Justin Richer has developed a plugin for the Elgg social networking platform, based on the basic PHP library. This library allows Elgg to act as both an OAuth client (to access other services) and server (allowing OAuth-protected access to the Elgg API). The library supports both version 1.0 and revision 1.0a simultaneously. Documentation can be found on the Elgg wiki.
  • Zend_OAuth was contributed by Pádraic Brady. The source code can be found here.
Damien Overeem
  • 4,487
  • 4
  • 36
  • 55
  • -@Damien, thanks. The point of using SO for this is to generate a consensus Q&A. While anyone can Google search for your sitepoint link, there are no metrics associated with it like there are on SO to know whether that is a good implementation. – tim peterson Nov 13 '13 at 12:45
  • Also your Sitepoint link appears to be a OAuth 1.0 implementation which isn't necessarily what one wants. – tim peterson Nov 13 '13 at 12:51
  • That is why i expanded my answer with more references. The real problem is that you ask for a "simple" demo, but the definition of "simple" can be very broad. It will be hard for anyone to find an example that -you- will find simple. It might be simple for them, but too complex for you. That is why nobody will be able to give a solid answer to this question. I hope the links help though. – Damien Overeem Nov 13 '13 at 12:53