MySpace Open Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

401 Error using OAuth to send REST API calls

Last post 11-03-2009 10:42 AM by Harakiro. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-11-2008 9:50 PM

    • Nick
    • Not Ranked
    • Joined on 12-06-2008
    • Posts 3

    401 Error using OAuth to send REST API calls

    I am trying to figure out how to use the rest API, and keep getting 401: Invalid digital signature for base string.  here's what I do:

    1) go to "myapps", and click "view development version"

    2) read the output from the php file

    3) cut and paste the necessary values into an http request:  (the values in the request below that i would insert are oauth_nonce, oauth_signature, and oauth_timestamp)

    http://api.myspace.com/v1/users/33543055.xml?oauth_consumer_key=http://nick.imgdrop.net/myspace/&oauth_nonce=633646555054520986&oauth_signature=3I7CyqzxJ/49TZLIatD4I6n3JWY=&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1229058407

    4) I enter that into the url, and try loading the page, however the result is 401 invalid digital signature for base string...

    5)  I compare this using the OAuth tool found here: http://developer.myspace.com/modules/apis/pages/oauthtool.aspx and the url that I'm using, and the one that they generate are the exact same with the exception of the variables I mentino in step 3.

     I've also tried using the files Jerome made: http://developer.myspace.com/Community/forums/t/157.aspx, and used the index.php from downdoggy.com: http://downdoggy.com/info/myspace-developer.php.  I also get a 401 error though, that nearly everyone got in the thread, but there is no mention on how to solve it...

    What am I doing wrong?

    Here is my index.php, the OAuth.php is the standard OAuth.php file that myspace recommends.

    <?php
     
     require_once('OAuth.php');

    $secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
    $consumer = $_SERVER['SCRIPT_URI'];

    $sig = OAuthRequest::from_request()->build_signature(
                                new OAuthSignatureMethod_HMAC_SHA1(),
                                new OAuthConsumer( $consumer, $secret),
                                new OAuthToken(null,null)
                       );      
                     
    $remote_sig = $_GET['oauth_signature'];
    $oauth_nonce = $_GET['oauth_nonce'];
    if( $sig == $remote_sig )
            echo "authenticated";

    ?>
     

  • 12-12-2008 1:22 PM In reply to

    • Nick
    • Not Ranked
    • Joined on 12-06-2008
    • Posts 3

    Re: 401 Error using OAuth to send REST API calls

     In case anyone reads this, I found out what I was doing wrong, I decided to start over and create a brand new myspace app, and leave all the settings default, and it ended up working.  It turns out the problem was setting "Use External Domain".  I probably had it setup wrong or something like that.

     Anyways, long story short, here's how you can make it work step-by-step:

    1)  Download the fils from this thread: http://developer.myspace.com/Community/forums/t/157.aspx

    2) put those files on a server somewhere (doesn't really matter)

    3) register for a new myspace app, DON'T CHANGE ANYTHING not mentioned here (unless its required to crate the app, like name, description, and category).

    4)  under "Edit App Source"->"Canvas Surface"->"App Type", select "External IFrame"

    5) In External IFrame Url, on the same page, type the URL of your page that you want loaded (ie: the place where you put the three files that you downloaded, for me it is: http://nick.imgdrop.net/myspace/)

    6)  open index.php on your server, and modify $key = 'http://www.myspace.com/xxxxxxx';  to be the path specified in "Edit App Information"->"OAuth Consumer Key" so it should look something like this now: $key = 'http://www.myspace.com/123456789'

    7)  Modify $secret = 'xxxxxxxxxxxxxxxxxxxxxxxxx';  to be the value found in  "Edit App Information"->"OAuth Consumer Secret", so it should look something like this: $secret = '12345678901234567890';

    8) modify  $mySpaceID = '33543055'; to be the userID of somebody you're trying to get the information from, or modify their data.

    9) you should be good to go now, just open up your app page either through myspace, or directly, and you should see a print-out of whatever information you're trying to get.

     

    Hope this helps,

    Nick

  • 10-09-2009 11:09 PM In reply to

    • Vivek
    • Not Ranked
    • Joined on 10-09-2009
    • Posts 1

    Re: 401 Error using OAuth to send REST API calls

    hi but i am not able to resolve this erro...

    My consumer key is still same ans correct ans secret key is also correct....

    still not able to reslove this error...

    please help

  • 10-10-2009 8:09 AM In reply to

    Re: 401 Error using OAuth to send REST API calls

    I honestly think it's completely busted - and no comformation from Myspace that it is - just leaves their developers guessing and second-guessing themselfs.

    Very unfriendly like.
  • 11-03-2009 10:42 AM In reply to

    Re: 401 Error using OAuth to send REST API calls

    Please download the latest SDK at: http://code.google.com/p/opensocial-php-client/source/checkout

    This new PHP SDK is a much improved library that is activily maintained and is working with all of our newest v0.9 REST endpoints. There are several examples for nearly every request so it should make getting rampped up and on your way easy to do.

     Thanks,

    Jesse

     

     

Page 1 of 1 (5 items)