Authentication when uploading images

27 views
Skip to first unread message

o.sv...@gmail.com

unread,
May 2, 2015, 7:10:11 PM5/2/15
to im...@googlegroups.com
I'm fairly new at using OAuth2, and was wondering what the best practices are for uploading images when dealing with token expiration:

- Should I upload with the current token, and then refresh the token and re-upload the image if the token has expired (seems pretty inefficient)

- Or, is there any easy way to check that the current token hasn't expired without posting all of the image data and waiting for the response?

- Otherwise, I guess I could refresh the token automatically if it's over 55 minutes old, but that seems a little messy, but would work I guess.

Does anyone know of the best methods for doing this? I'm basically trying to avoid posting the image data twice to Imgur!

@jasdev

unread,
May 3, 2015, 6:15:33 PM5/3/15
to im...@googlegroups.com
We tend to use a mix of the first and third methods. Locally, keep track of token expiration times from the OAuth2 responses, if the time has passed, you know you'll need a refresh, prior to uploading the image. As a worst case fallback, I'd include some logic to handle a refresh and re-POST of the image in the case of a token error.

Hope this helps!

Jasdev
Reply all
Reply to author
Forward
0 new messages