开发者

How do I check if a Twitter OAuth access_token is still valid?

开发者 https://www.devze.com 2023-04-05 23:25 出处:网络
I\'m writing a Django app and I want users to be able to supply their Twitter username and connect their Twitter account with their User in my app. (I\'m not using Twitter to log them into my site; I

I'm writing a Django app and I want users to be able to supply their Twitter username and connect their Twitter account with their User in my app. (I'm not using Twitter to log them into my site; I just want them to connect their Twitter account with their account on my site, and give permissions for certain actions.)

Assuming I do that successfully, and I get back and store an access_token for the user, what's the best way to subsequently check that the access_token is still valid? i.e开发者_如何学编程., if the user has later revokes access to my service on their Twitter account, I want to be able to check the access_token and, if it's invalid, delete it and prompt the user to re-authenticate.

The Flickr API has flickr.auth.checkToken and I guess I'm looking for the equivalent functionality with the Twitter API.


using python-twitter, you can verify if the credentials are ok using:

if api.VerifyCredentials() is not None:
0

精彩评论

暂无评论...
验证码 换一张
取 消