What are OAuth Services:
OAuth Services allow you to talk to external services that utilize OAuth authentication. You can register third party OAuth services with the Jive Apps Gateway via the command line.
Getting a list of OAuth services associated with your app:
Run "jiveapps info" to list any oauth services associated with an app, along with all other app metadata. Or run "jiveapps oauth" to list the services for this app, without the other app metadata:
$ cd foo_bar_app $ jiveapps oauth No OAuth Services for foo_bar_app
No OAuth services are currently defined.
For the app "foo_bar_app", I plan to integrate with Twitter, so I'll setup a Twitter OAuth service. First, go to the Twitter developer site and create a new application.
- Go to dev.twitter.com/apps
- Login and click "Register new app"
- Enter in your application's title, description, website and organization name.
- Select "Browser" as the app type.
- Set the callback URL to "http://gateway.jivesoftware.com/gateway/oauth/callback"
- Choose "Read & Write" so your app may update a user's twitter status.
- Finish filling out the form and register the app.
- Once your app has been registered, Twitter will display your OAuth 1.0a Settings.
Note the consumer key and secret, and register a new oauth service on the command line:
$ jiveapps oauth:add twitter your_consumer_key your_consumer_secret === Registering a new OAuth Service: "twitter" === 1 OAuth Service for foo_bar_app 1. "twitter" Service Consumer Key: your_consumer_key Consumer Secret: your_consumer_secret
Now, inside your app's main gadget XML file, define the OAuth service using the same service name you registered on the command line, and the URLs supplied by Twitter for request token, access token, and authorize URL:
<Module> <ModulePrefs title="..."> ... <OAuth> <Service name="twitter"> <Access url="http://api.twitter.com/oauth/access_token" method="POST" /> <Request url="http://api.twitter.com/oauth/request_token" method="POST" /> <Authorization url="http://api.twitter.com/oauth/authorize" /> </Service> </OAuth>
Deregistering OAuth services:
If you want to remove an OAuth service, there's a command for that too:
$ jiveapps oauth:remove twitter Are you sure you wish to remove the OAuth service "twitter"? (y/n)? y === Removing Oauth Service "twitter" No OAuth Services for foo_bar_app
This concludes the tutorial on how to use the command line tools to register an OAuth service for your app. To continue with the Twitter example tutorial and see the full source code for the app, read more on Using OAuth in your applications.