Rails omniauth - twitter asking for app authorization each time user logs in

前端 未结 7 784
情歌与酒
情歌与酒 2021-02-06 13:48

In Railscast: http://railscasts.com/episodes/241-simple-omniauth Ryan uses omniauth for logins. In the video when he clicks on the login button the first time Twitter asks the u

7条回答
  •  再見小時候
    2021-02-06 14:22

    If you originally had you application permissions set to "Read and Write" and later added the "Access Direct Messages" permission AFTER you had authenticated once, then subsequent authentication attempts will cause the "Sign in" page to reappear. But, notice you'll see that the app will still NOT have permission to access direct messages for that user. This is because your app is now trying to ask for direct message permissions, but your access token was setup originally just for read/write.

    I found this discussion where @toptwetcom mentions that your access token (Not the App API key) must be regenerated after an app permissions change. I'm still in dev mode, but here's what worked for me:

    1. Go to https://apps.twitter.com, find your app and go to the Permissions tab
    2. Change permissions to "Read, Write, and Access Direct Messages" if you haven't already. (It sometimes takes a minute for the changes to show—keep refreshing!)
    3. Go to the API Keys tab (still for the application)
    4. Click "Regenerate my access token" button and confirm.
    5. Sign out of your app (if not already)
    6. In your app, sign back in with Twitter (and reauthorize your app).

    If you now go to https://twitter.com/settings/applications you should see that you've given "read, write, and direct messages" permissions to your app. Also if you logout of your app and log back through Twitter, it should "just work" (given you are already signed in with Twitter).

    Also, be sure to read @JasonLogsdon's answer.

提交回复
热议问题