Services OAuth: anyone have any idea how to configure?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
bsenftner's picture

I think the subject says it all. The Services OAuth module has no end user documentation, and looking at the interface pages I'm not sure what to do.
Anyone know of documentation for usage of the Services OAuth interface? All I can find is non-drupal specific OAuth docs for developers authoring an OAuth implementation, but not how to configure such an interface once it is there.

If you know how to use the Services OAuth module's interface, could you please write something up and post where that can be found?

Comments

Same problem here. I found

mottolini's picture

Same problem here. I found examples related to an iPhone Application talking to an oauth service in drupal here, but there isn't any step by step guide to configure and implement oauth services on drupal.
What I found more frustrating is that it's even really difficult to understand which modules should be used. Should I go with services_oauth 1.x and services 2.4 or should i use services 3.0 directly?

I decided to stay away from services 3.0 and I'm currently working with services_oauth 1.x and services 2.4. If I'll make any progress, I'll post it here.

We're aware of it and have an

voxpelli's picture

We're aware of it and have an issue for it: http://drupal.org/node/1007354

Services 3.x has Services OAuth bundled with it. Services 2.x needs the separate module but that one is no longer actively maintained.

Barnettech's picture

To get Oauth working on Ubuntu I had to do the following.


#apt-get install php5-dev

# apt-get update

# apt-get install libpcre3 libpcre3-dev

#pecl install oauth

in /etc/php5/ under apache and cli in php.ini I added the line

 extension=oauth.so 

and then restarted apache

barnettech, Are you using the

bsenftner's picture

barnettech,

Are you using the Services OAuth module? I'm seeking how to configure OAuth inside web pages presenting the Drupal Services OAuth configuration UI.

no but I thought the setup might be the same

Barnettech's picture

No but I thought the setup might be the same. I didn't see how the OAuth could work without the same libraries I was using to integrate dropbox. Just trying to be helpful.

Thanks for your input. I'm

bsenftner's picture

Thanks for your input. I'm sure you post will be useful to others.

The PECL-library isn't used

voxpelli's picture

The PECL-library isn't used by the Drupal OAuth module - it comes with its own library. Since OAuth is a standardized protocol there exists plenty of libraries.

Seeing the end of the tunnel...

mottolini's picture

I spent last day, after a week of useless googling, trying to figure out how to configure this module.
I'm really disappointed for it: it's unbelievable that nobody with the right knowledge had 5 minutes to write a simple note for all of us dummy users.
Anyway, this is the dark side of open source: you want it free, pay with your time, always thanking anybody who spent his time before you to develop or document something.
So, I'm here to write what I found out, with the hope that could be useful to someone else.

First of all my setup:

  • drupal 6.20
  • services 6.x-2.4
  • json server 6.x-2.0-alpha2
  • services_oauth 6.x-1.0-beta6
  • oauth_common 6.x-1.0-beta5

Why I choose this outdated setup instead of going directly with services 3.0? Because I really didn't understand how to set it up and which modules I have to add to get same functionality.
When you have all these modules installed, with their dependencies, follow these steps:

1) being User 1, go to My Account, click on Applications tab and then on Add Application. This create a Consumer Key and Consumer secret that an external app needs to have to initiate an OAuth authorization. So write down these two strings.
2) go to Services Settings (/admin/build/service/settings) and choose OAuth authentication as the Authentication Module
3) activate any data services you want to give access to your external application in the modules list (you find them under Services - services in /admin/build/modules/list)
4) if you want to allow your registered users to access your data from an external app with OAuth, go to Permissions (/admin/user/permissions) and give them "oauth authorize consumers" permission

That's all!
Ok, but how do I know that it's working?
You should have an external app able to "talk" OAuth to your Drupal Server...
I found an interesting demo app at http://oauth.googlecode.com/svn/code/php/. Download everything and copy the sources in a web server root, then point your browser at /example/client.php
In "endpoint" write "http://youdrupalserver/oauth/request_token" (of course substitute "yourdrupalserver" with your server url)
In "consumer key" paste the consumer key generated at step 1.
In "consumer secret" paste the consumer secret generated at step 1.
Press "request_token".
You should receive back a string in the form oauth_token=xxxxxxxxxxxxxxxx&oauth_token_secret=yyyyyyyyyyyyyyyy. Our drupal server gave us a token and its secret that we need to use later, so write them down somewhere.
Go back to /example/client.php and change "endpoint" to "http://youdrupalserver/oauth/authorize".
Be sure you still have your "consumer key" and "consumer secret" in the appropriate fields and fill "token" and "token secret" (just below) with the strings we got previously. Press the button "authorize".
You should be redirected to a page on your drupal server where you have to authorize the external app. This happens because the external app you are using is asking to access your data on drupal and OAuth wants to know if you really agree on that. This has nothing to do with the app creation at step 1. You need to create app credentials once for each external app. Then, each user of the app has to authorize it to access data on your drupal server.
So, give it full access and you should be redirected back to /example/client page.
Your fields should be already filled, if not fill them up with the same infos.
Change "endpoint" to "http://youdrupalserver/oauth/access_token" and press the button "access_token".
You should receive back a string in the form oauth_token=xxxxxxxxxxxxxxxx&oauth_token_secret=yyyyyyyyyyyyyyyy: store them somewhere because you need them later.
This means that the external app you are using is now authorized to access your data on Drupal, without giving it your username and password.

Next step is to call a service on drupal using this access token you just received, but so far I've been unsuccessful.
I'm trying to get some data through the json server but I still have to figure out how to do it.
More news later, I hope...

Out of the tunnel

mottolini's picture

Finally I was able to call a method with OAuth authentication to get a Json object.
Json server only accepts POST request, so I created a simple form modifying client.php (see previous post).
The parameters you have to send are:

  • method
  • any parameter of the method call
  • oauth_consumer_key
  • oauth_nonce
  • oauth_signature
  • oauth_signature_method
  • oauth_timestamp
  • oauth_token
  • oauth_version

oauth_token is the access token received when you called http://youdrupalserver/oauth/access_token. oauth_nonce, oauth_timestamp and oauth_signature are calculated by the oauth library on your client. Be sure to provide the oauth_token_secret received with last call.
There is a bug in the json server that prevents oauth autenthication to work, but I fixed it and everything worked like a charm.
With other server you should be probably just careful to provide all parameters outlined above.

Thanks for sharing this with

iamnayr's picture

Thanks for sharing this with us. I too have been having a heck of a time figuring this all out. Unfortunately, I can't follow your method exactly as I'm working with the Drupal 7 version of everything, which appears to be....well...further behind on development at this point.

make sure to use the dev

kylebrowning's picture

make sure to use the dev version, its actively in development.

Happy to know, just remember

mottolini's picture

Happy to know, just remember to write here how you made it happen, so that can be useful to others as well...

Really helpful!

DevElCuy's picture

Thanks a lot for sharing this, I've been debugging for hours, so you saved me a week of work"

--
[develCuy](http://steemit.com/@develcuy) on steemit

You can check my module for

Sylvain Lecoy's picture

You can check my module for OAuth with Drupal 7. Provides an interface to PECL OAuth and basic identities management.

Here is my sandbox: http://drupal.org/sandbox/SylvainLecoy/1127118

Thanks a lot for sharing this

arsura2's picture

Thanks a lot for sharing this mottolini.