About
The OAuth plugin provides oauth-capabilities for Pimcore. Its a base for other other plugins that will need oauth to use APIs from service providers. In order to write your own plugin which should be able to use OAuth follow the steps as described in usage.
Installation
When downloaded just hit the install button. Thats it.
Usage in your plugin
In your plugins install method do the following:
OAuth_Plugin::registerConsumer(new Your_ConsumerClass());
Your_ConsumerClass has to implement OAuth_Interface_Consumer. Your class must provide a getConfig() Method.
The getConfig() Method should return a Zend_Config object that includes the following:
siteUrl: 'Service Providers base url' e.g. http://api.provider.com/oauth
If accessTokenUrl and requestTokenUrl etc. are different from the default OAuth protocol scheme, you have to provide these urls as well. To see a full example you can have a look on the Soundcloud plugin source code.
Next steps
When your registered plugins isInstalled() Method returns true, the OAuth plugin shows the credentials form for it like so:

You first have to get a consumer key and a consumer secret from your service provider. When you have them, simply enter those in the credentials form. When finished, hit the CONNECT button. You will now be taken to the service provider where you have to authorize Pimcore (or more precisely: your plugin) to access data from your account over the service providers API.
API requests within your plugin
To make API calls within your plugin you simply have to get the OAuth HttpClient which holds the accessToken and all the other protocol related information.
$yourConsumerModel = new Your_ConsumerModel(); // Your_ConsumerModel implements OAuth_Interface_Consumer $oAuthHandler = new OAuth_Handler($yourConsumerModel); $httpClient = $oAuthHandler->getAccessHttpClient(); $httpClient->setMethod(Zend_Http_Client::GET); $httpClient->setUri($requestUri); $response = $httpClient->request(); $body = $response->getBody(); //... do whatever you need here with the response
As you can see - the handling is basically just the same as if you would use the standard Zend_Http_Client.