How to Add a Login with a Twitter Button
Download the Twitter OAuth package which you will be using to set up the login using a Twitter button., Import the TwitterOAuth class onto your page and initialize the connection., Create a Twitter App on the Twitter dev site at...
Step-by-Step Guide
-
Step 1: Download the Twitter OAuth package which you will be using to set up the login using a Twitter button.
Go to https://github.com/abraham/twitteroauth for the import. , This will service the requests for the Twitter social login for your site. , <Consumer Secret>
- The Consumer Secret found in the created app found under Keys and Access Tokens. <Callback Location>
- The URL that you would like a user to return to after successfully authenticating. , From the response object capture the “oauth_token” and “oauth_token_secret” for further use. ,, Once a user has successfully authenticated they will be redirected to the location that you specified in the request_token OAUTH_CALLBACK URL. ,,,, At this point your user is logged in and you can make calls to the Twitter social login APIs.You have successfully set a login using Twitter on your page! -
Step 2: Import the TwitterOAuth class onto your page and initialize the connection.
-
Step 3: Create a Twitter App on the Twitter dev site at https://dev.twitter.com/.
-
Step 4: Replace the above definitions with the following details from your App: <Consumer Key> - The Consumer Key found in the created app found under Keys and Access Tokens.
-
Step 5: Generate a Request token that will be used to generate a URL which will trigger the Twitter Authentication popup.
-
Step 6: Generate the URL to be used to display the Twitter social login Authentication interface.
-
Step 7: Set up a button or trigger to cause users to navigate to the URL which will display the Twitter social login interface.
-
Step 8: On your Callback page
-
Step 9: import the TwitterOAuth class again.
-
Step 10: Initialize the connection using the stored “oauth_token” and “oauth_token_secret”.
-
Step 11: Request an access_token to be used to access user data and actions.
Detailed Guide
Go to https://github.com/abraham/twitteroauth for the import. , This will service the requests for the Twitter social login for your site. , <Consumer Secret>
- The Consumer Secret found in the created app found under Keys and Access Tokens. <Callback Location>
- The URL that you would like a user to return to after successfully authenticating. , From the response object capture the “oauth_token” and “oauth_token_secret” for further use. ,, Once a user has successfully authenticated they will be redirected to the location that you specified in the request_token OAUTH_CALLBACK URL. ,,,, At this point your user is logged in and you can make calls to the Twitter social login APIs.You have successfully set a login using Twitter on your page!
About the Author
Kathryn Harvey
Committed to making DIY projects accessible and understandable for everyone.
Rate This Guide
How helpful was this guide? Click to rate: