"invalid API key" on rest api calls

auserauser Registered Users Posts: 2 Beginner grinner
This is my first time trying to use the API.

I login with https://api.smugmug.com/services/api/rest/1.2.2/?method=smugmug.login.withPassword&APIKey=...&EmailAddress=...&Password=...

and get a response with stat="ok" and a session id.

Then I try: https://api.smugmug.com/services/api/rest/1.2.2/?SessionID=...&method=smugmug.categories.get

and I get <rsp stat="fail"><method>smugmug.categories.get</method><err code="18" msg="invalid API key"/></rsp>

I tried a few different methods, always with the same result. What's wrong?

Comments

  • auserauser Registered Users Posts: 2 Beginner grinner
    edited April 21, 2012
    I got it to work. I used wget with "--save-cookies /tmp/cookies.txt --keep-session-cookies" for the login.withPassword, and "--load-cookies /tmp/cookies.txt" on the subsequent categories.get. Is the requirement of having cookies enabled documented anywhere?
  • olegosolegos Registered Users Posts: 94 Big grins
    edited May 10, 2012
    Just wanted to say thanks for posting this. I was trying to use the API from perl, and was running into this error too. Your posts helped me along.

    This is all I needed to do in perl to enable cookies:

    use HTTP::Cookies;
    
    my $cookie_jar = HTTP::Cookies->new(
        file => "sm_cookies.dat",
        autosave => 1,
      );
    
    my $ua = LWP::UserAgent->new;
    $ua->cookie_jar($cookie_jar);
    
Sign In or Register to comment.