Tell me more ×
SmugMug Stack Exchange is a question and answer site for SmugMug developers and end users. It's 100% free, no registration required.

I'm using this example of smugpy with oauth to authenticate. But now that I have the key and secret for my API Keys I'm wondering if there's a way to not have to use a browser to manually reauthorize. Can I just pass in the key and secret programmatically and skip the browser?

I've tried

smugmug.auth_getRequestToken(oauth_consumer_key=API_KEY, oauth_token=OAUTH_SECRET)

but I get the error

smugpy.SmugMugException: SmugMug API Error for method smugmug.albums.get: (36) invalid/expired token

Thanks

share|improve this question
Once you have your oauth_token and oauth_token_secret, instantiating the SmugMug object looks like: smugmug = SmugMug(api_key=API_KEY, oauth_secret=OAUTH_SECRET, oauth_token = OAUTH_TOKEN, oauth_token_secret = OAUTH_TOKEN_SECRET, app_name='whatever') – Everett Toews Jun 23 '12 at 15:44

1 Answer

up vote 1 down vote accepted

You need to save the keys that smugpy receives after the first time you get redirected to the browser. In other words, the first time, you need to:

  • create smugpy.SmugMug object with api_key and oauth_secret
  • getRequestToken()
  • authorize using the browser
  • getAccessToken()
  • save oauth_token et oauth_token_secret from the smugpy.SmugMug object somewhere (like a text file).

After that you just need to retrieve oauth_token and oauth_token_secret and use them as additional parameters when creating the smugpy.SmugMug object. No need to request new tokens then, you're all set.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.