Getting access to the SessionId from within the SmugMug Website.

esacesac Registered Users Posts: 47 Big grins
I do not know if this is possible, however, to get what I want in a website, I am resorting to using the SmugMug API. The problem is that inside of the javascript (Top/Bottom Javascript), in order to use the API, I would have to embed my API key, username and password.

Instead of that, I was hoping that it would be possible to get access to the session id in the context of the user for that smugmug site. Or rephrased, this session id for rjakbennett.smugmug.com would be the session id as if I had logged into the website.

I would assume it would be easy enough to restrict access for using this session id only to requests originating from smugmug.com so it shouldn't be insecure.
Bennett Family Gallery http://rjakbennett.smugmug.com

Comments

  • SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited May 29, 2010
    If you use the login.withHash method, you don't have to put your actual login/password there. However, anyone will be able to login using the hash as well. I would use some sort of server-side php script and phpsmug to login and get the info you need and then something else to parse that info.
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited June 1, 2010
    You need to use smugmug.login.withSession, this will configure the user's session to use the API. Note: that this method call doesn't require or return the SessionID parameter, it uses the session that is in the user's cookie. As long as the method returns without error, you are good to go.

    Then just call whatever methods you need to, and just omit the SessionID parameter...the SessionID will be loaded from the cookie if it's not sent.

    Hope this helps,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • esacesac Registered Users Posts: 47 Big grins
    edited June 3, 2010
    Actually not quite what I am looking for, but I gave that up, and this will help for what I am doing next.

    Thanks
    Bennett Family Gallery http://rjakbennett.smugmug.com
  • SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited June 4, 2010
    devbobo wrote: »
    You need to use smugmug.login.withSession, this will configure the user's session to use the API. Note: that this method call doesn't require or return the SessionID parameter, it uses the session that is in the user's cookie. As long as the method returns without error, you are good to go.

    Then just call whatever methods you need to, and just omit the SessionID parameter...the SessionID will be loaded from the cookie if it's not sent.

    Hope this helps,

    David
    Interesting! Learned something new! clap.gif Something tells me I'll find this very useful in the future. thumb.gif
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • brianbbrianb Registered Users Posts: 96 Big grins
    edited June 20, 2010
    The smugmug.login.withSession API is not listed on the 1.2.2 API index page. Are the 1.2.2 API docs current or waiting for an update?
  • keiths2112keiths2112 Registered Users Posts: 7 Beginner grinner
    edited January 9, 2011
    Do we have a good example of this? I assume you have to have an api key to get this to work? I am just wondering if a I can do something like this:

    In a gallery description where I have lots of html code add the following:
    <script language="javascript" type="text/javascript">
       smugmug.login.withSession();
       smugmug.albumns.getInfo ("albumbId", "albumKey", myCallback);
    
       function myCallback (returnStr)
       {
          var cbObj = eval (returnStr);
          // do stuff with the object here
       }
    </script>
    
    Really, at the end of the day, I want to be able to use the API inside my customization code (whether at the site wide level or at and individual page level).
Sign In or Register to comment.