background preloader

OAuth

Facebook Twitter

Bshaffer/oauth2-server-php. Creating a PHP OAuth Server. If you’ve ever integrated with another API that requires security (such as Twitter), you’ve probably consumed an OAuth service. In this article, I’ll explore what it takes to create your own three-legged OAuth server allowing you, for example, to create your own secure API which you can release publicly. When dealing with OAuth, you will typically see it implemented as a two-legged or three-legged OAuth server. The major difference between them is that two-legged authentication doesn’t involve another user. For example, if you want to access a specific user’s Twitter information, you would consume the three-legged server because an access token must be generated for the user in your application, versus just Twitter providing you a token.

We’ll focus on the three-legged variety since it’s more practical for real-world use. We’ll use oauth-php to perform a lot of the heavy lifting for us. Understanding the Flow Setting up the Database Creating the OAuth Server Allowing Registration Summary. Writing an OAuth Provider Service | Rasmus' Toys Page. Last year I showed how to use pecl/oauth to write a Twitter OAuth Consumer. But what about writing the other end of that? What if you need to provide OAuth access to an API for your site? How do you do it? Luckily John Jawed and Tjerk have put quite a bit of work into pecl/oauth lately and we now have full provider support in the extension. Step 1 - Create a Consumer Key registration page In order for an application to communicate with your service you assign it what is essentially a user id and password. Cat /proc/sys/kernel/random/entropy_avail In general something like the following should give you a decent random string of characters that you can use for your CK and secret: You can of course read more entropy and use a longer hash, like sha256 or whirlpool if you want longer keys.

Step 2 - The OAuth endpoints It would probably be a good idea to skim the OAuth Spec at this point. This makes the pecl/oauth extension do all the heavy lifting for us. Step 3 - Authorizing the request token. Guía para desarrolladores: protocolo del API de datos – OAuth para aplicaciones web - YouTube. Oauth_diagram.png (824×548)

OAuth.