Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

7. Authenticating with External Services > Example: Sign in With Twitter

Example: Sign in With Twitter

Let’s walk through an example that uses the Twitter API to authenticate a user. This application will redirect a nonlogged-in user to Twitter’s authorization page, which prompts the user for his screenname and password. Twitter then redirects the user to a URL you specify in Twitter’s application settings page.

First, you must register a new application on Twitter. The Twitter Developers site has a “Create an app” link where you can get started, if you don’t have an app already. Once you create your Twitter application, you will be assigned an access token and a secret that identifies your application to Twitter. You’ll need to fill in those values in the appropriate places in the source code we show in this section.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint