Getting Started with the API

Micah
Micah
edited February 2011 in API Discussion
If you're brand new to the API, here are some resources to check out:

* "Official API Documentation":http://help.obsidianportal.com/kb/api/api-overview

Comments

  • Shammond42
    Shammond42
    Posts: 65
    So, I'm working with wiki pages and adventure log posts. I understand that they are really the same thing, but it would be nice to have the option to filter the wiki's api to just return an array of one or the other.

    /v1/campaigns/campagin_id/wikis.json?type=Post

    I fear that for a large campaign, I would have to download and parse a lot of data I don't need if I am only interested in posts or pages. I would rather filter have the filter on the API end.

    Thanks,
    Steve
  • nwmotogeek
    Posts: 4
    How do you register a new app? This link 'http://www.obsidianportal.com/oauth_clients/new' doesn't work.
  • Micah
    Micah
    Posts: 894
    Sorry, was a typo in the docs. The correct URL is: http://www.obsidianportal.com/oauth/clients/new

    Steve, I'll look into your request. Seems reasonable...
  • nwmotogeek
    Posts: 4
    I'm trying to use signpost (http://code.google.com/p/oauth-signpost/) and their instruction indicate that I will need a 'verification code' that is provide by the call_back method but if I am a desktop application how do I obtain this verification code?
  • glumlord
    Posts: 1
    I may be clueless but when I go to http://sunrod.codeplex.com/

    I don't see a download link for the .net libraries.

    Where can I actually download the .dll files or the source code? I'm interested in playing around to see what sort of capabilities are available with these API's
  • Shammond42
    Shammond42
    Posts: 65
    I've been working on a command line app. I have the user paste the authorization_url into their browser. After they authorize the app, they'll get a web page with the verification code on it.They can paste that into the app and they'll be good to go.

    If your desktop app has an embedded browser you may be able to scrape it directly from the page or handle it like a regular web app integration, but I haven't tried that yet.

    Steve
  • nwmotogeek
    Posts: 4
    I have the following java code using oauth-signpost (http://code.google.com/p/oauth-signpost/) and on the provider.retrieveRequestToken() line the program returns "Server returned HTTP response code: 401 for URL: https://www.obsidianportal.com/oauth/request_token". I'm stuck and don't know where the problem is here, any advice would be appreciated.


    OAuthConsumer consumer = new CommonsHttpOAuthConsumer(MYKEY, MYSECRET);
    OAuthProvider provider = new DefaultOAuthProvider( "https://www.obsidianportal.com/oauth/request_token"
    , "https://www.obsidianportal.com/oauth/access_token"
    ,"https://www.obsidianportal.com/oauth/authorize");
    try
    {
    String url = provider.retrieveRequestToken(consumer, oauth.signpost.OAuth.OUT_OF_BAND);
    } catch (Exception e) {
    e.printStackTrace();
    }
  • Shammond42
    Shammond42
    Posts: 65
    I don't know oauth-signpost and my java is rusty. What you have there looks OK, though. Do you hae MYKEY and MYSECRET correct? That seems the most likely culprit for a 401 error getting the request token.

    Steve
  • nwmotogeek
    Posts: 4
    oops, you are absolutely right I was missing a character from MYKEY, now I have another questions. :)

    provider.retrieveAccessToken(consumer, verificationCode);

    Where do I get the verificationCode?
  • Shammond42
    Shammond42
    Posts: 65 edited February 2011
    Here is a Ruby snippit from my commandline app. Maybe that will help you. The important bit is that once I have a request token, that token has an authorize_url. This is the url for the user to go to authorize your app to access their OP account. Below, you can see that I have the user paste that into their browser. That will bring them to a page where they can click "Authorize" to authorize your app. After clicking authorize, they will go to a page with the verify token on it. The user can cut and paste that token into your app. That become your verificationCode.

    This process is much cleaner for a web app, because the urls and redirection eliminate the need for all of the cut and paste.


    bc.. def authorize
    request_token = Configuration.client.consumer.get_request_token

    if Configuration.auth_token && Configuration.auth_secret
    begin
    print "Chronicler has already been authorized. Do you want to authorize again?[Yn] "
    auth_again = STDIN.readline.chomp
    end until auth_again =~ /^[yYnN]?$/
    return if auth_again =~ /^[nN]$/
    end

    puts "Put #{request_token.authorize_url} in your browser"

    print "Enter the supplied pin (or verifier): "
    pin = STDIN.readline.chomp

    access_token = request_token.get_access_token(:oauth_verifier => pin)
    Configuration.auth_token = access_token.token
    Configuration.auth_secret = access_token.secret

    # print "Enter token: "
    # Configuration.auth_token = STDIN.readline.chomp
    # print "Enter secret: "
    # Configuration.auth_secret = STDIN.readline.chomp

    Configuration.save!
    puts "Saved authorization information." if Configuration.verbose
    end
    @
    Post edited by Shammond42 on
  • Micah
    Micah
    Posts: 894
    Since the OAuth verifier question has come up a lot, I've gone ahead and added it to the "OAuth Overview Page":http://help.obsidianportal.com/kb/api/api-authentication-oauth in the docs.
  • sozin
    sozin
    Posts: 20
    I put a Python version of the above ruby code over at https://github.com/lhayhurst/oppy
  • sozin
    sozin
    Posts: 20
    Micah, is this project on hiatus?
Sign In or Register to comment.

November 2021
Star Trek Odyssey: Laurels of Victory

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions