SOLUTION:- Twitter Login API Asking for user's authorize permission each time
When we integrate twitter login in NodeJS, PHP, express, react, Fastify or any framework, we face an issue like if a user is logged in by using twitter OAuth and granted permission to access twitter profile data, and if he logged out from our site try to login again, twitter ask for permission each time. So today we solve this problem by using a simple change
Open your code and find https://twitter.com/oauth/authorize?oauth_token= in your code. this is the URL where we redirect to the user after clicking on 'Login with twitter' in our website, and here we are using authorize() function of twitter API that functions always ask for permission to the user each time he tries to log in, so instead of authorizing function we will use authenticate() that will check if a user is already logged in then it will not show permission popup and redirect the user to callback URL.
To Replace
https://twitter.com/oauth/authorize?oauth_token=YOURTOKEN
with
https://twitter.com/oauth/authenticate?oauth_token=YOURTOKEN
You can check twitter API for more details in twitter documentation https://developer.twitter.com/en/docs/basics/authentication/api-reference/authenticate
Important Links
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete