Why is my twitter oauth access token invalid / expired

后端 未结 3 667
失恋的感觉
失恋的感觉 2020-12-09 10:07

I am using Twitter to log users into to a website, which seems to be working up until I attempt to obtain a valid Access Token.

require(\"twitteroauth.php\")         


        
3条回答
  •  暖寄归人
    2020-12-09 10:41

    If your OAuth flow was working one day and failing the next, check your computer's clock. I was running a Vagrant box that somehow had its time set to the day before, which caused the Twitter API to return {"code":89,"message":"Invalid or expired token."}. This may also appear as 401 timestamp out of bounds. You can use this command to update your clock in Ubuntu:

    sudo ntpdate time.nist.gov
    

    Alternative method if ntpdate isn't available on your system:

    sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
    

提交回复
热议问题