{"id":8354,"date":"2014-04-10T15:52:27","date_gmt":"2014-04-10T15:52:27","guid":{"rendered":"https:\/\/gosqeng.test\/?p=611"},"modified":"2019-11-28T12:11:47","modified_gmt":"2019-11-28T12:11:47","slug":"introducing-flutter-simple-twitter-api-auth","status":"publish","type":"post","link":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth","title":{"rendered":"Introducing Flutter"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" alt=\"\" src=\"https:\/\/static.gosquared.com\/images\/liquidicity\/14_04_09_flutter_01.png\" width=\"500\" height=\"500\" \/><\/p>\n<p>At GoSquared, we use the Twitter API to power our Twitter Search and Followers widgets. As a result we handle Twitter authentication for thousands of accounts. We need to ensure that the flow of authorising GoSquared with Twitter is as smooth as possible, and we need it to be easy for us to use the Twitter API to make requests to power our data.<\/p>\n<p>If you&#8217;ve ever worked with the Twitter API or any other service that requires OAuth authentication, you&#8217;ll know how incredibly fiddly it can be to get the authentication flow set up. To have it working properly, you need the necessary client tokens, request tokens, verifiers and access tokens. Simple getting your head around all the tokens and keys is hard enough with secrets everywhere.<\/p>\n<p>Enter <a href=\"https:\/\/github.com\/gosquared\/flutter\" target=\"_blank\" rel=\"noopener noreferrer\">Flutter<\/a>. Flutter is a minimal node module designed to take the hassle out of handling the Twitter authentication flow, and also has helper methods for making authenticated requests. We&#8217;ve just open sourced it on GitHub and you can find the repository\u00a0<a href=\"https:\/\/github.com\/gosquared\/flutter\">here.<\/a><\/p>\n<p>Here&#8217;s an example of how to set up an authentication flow using Flutter&#8217;s default options:<\/p>\n<pre><code class=\"language-javascript\">\nvar express = require('express');\nvar Flutter = require('flutter');\n\nvar flutter = new Flutter({\n  consumerKey: 'MY CONSUMER KEY',\n  consumerSecret: 'MY CONSUMER SECRET',\n  loginCallback: 'http:\/\/my-host\/twitter\/callback',\n  completeCallback: '\/someUrl'\n});\n\nvar app = express();\n\napp.get('\/twitter\/connect', flutter.connect);\n\n\/\/ URL used in loginCallback above\napp.get('\/twitter\/callback', flutter.auth);\n\n\/\/ Direct users to \/twitter\/connect to initiate oauth flow.\n\n\/\/ Users will be redirected back here once they're authenticated\napp.get('\/someUrl', function(req, res){\n\n  \/\/ credentials are stored on the request session so you\n  \/\/ can access them here and store them or make requests\n  var accessToken = req.session.oauthAccessToken;\n  var secret = req.session.oauthAccessTokenSecret;\n\n  \/\/ Make some API requests. Let's search for some bacon.\n  flutter.API.get(\n    'search\/tweets.json',\n    { q: 'bacon' },\n    accessToken,\n    secret,\n    function(err, results) {\n      console.log(results); \/\/ { statuses: [ { ...etc } ] }\n    }\n  );\n});\n<\/code><\/pre>\n<p>There are plenty of other options you can specify &#8211; for example there are several callbacks you can specify to catch authentication errors or save the credentials as soon as they&#8217;re retrieved. Check out the README over at the <a href=\"https:\/\/github.com\/gosquared\/flutter\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub repository<\/a> for a full list of available options.<\/p>\n<p><em>You can find other open source modules we&#8217;ve released <a href=\"https:\/\/www.gosquared.com\/labs\/\">here at GoSquared labs<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; At GoSquared, we use the Twitter API to power our Twitter Search and Followers widgets. As a result we&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1452],"tags":[],"class_list":["post-8354","post","type-post","status-publish","format-standard","hentry","category-engineering"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v18.6 (Yoast SEO v19.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Introducing Flutter - GoSquared Blog<\/title>\n<meta name=\"description\" content=\"Flutter is a minimal node module designed to handle the Twitter API authentication flow, and also has helper methods for making authenticated requests.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introducing Flutter\" \/>\n<meta property=\"og:description\" content=\"Flutter is a minimal node module designed to handle the Twitter API authentication flow, and also has helper methods for making authenticated requests.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth\" \/>\n<meta property=\"og:site_name\" content=\"GoSquared Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GoSquared\" \/>\n<meta property=\"article:published_time\" content=\"2014-04-10T15:52:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-11-28T12:11:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/static.gosquared.com\/images\/liquidicity\/14_04_09_flutter_01.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@floopily\" \/>\n<meta name=\"twitter:site\" content=\"@GoSquared\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"JT\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#organization\",\"name\":\"GoSquared\",\"url\":\"https:\/\/www.gosquared.com\/blog\/\",\"sameAs\":[\"https:\/\/instagram.com\/gosquaredteam\",\"https:\/\/www.linkedin.com\/company\/go-squared-ltd.\",\"https:\/\/www.facebook.com\/GoSquared\",\"https:\/\/twitter.com\/GoSquared\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png\",\"contentUrl\":\"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png\",\"width\":1270,\"height\":250,\"caption\":\"GoSquared\"},\"image\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#website\",\"url\":\"https:\/\/www.gosquared.com\/blog\/\",\"name\":\"GoSquared Blog\",\"description\":\"Turn visitors into customers.\",\"publisher\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.gosquared.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#primaryimage\",\"url\":\"https:\/\/static.gosquared.com\/images\/liquidicity\/14_04_09_flutter_01.png\",\"contentUrl\":\"https:\/\/static.gosquared.com\/images\/liquidicity\/14_04_09_flutter_01.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#webpage\",\"url\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth\",\"name\":\"Introducing Flutter - GoSquared Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#primaryimage\"},\"datePublished\":\"2014-04-10T15:52:27+00:00\",\"dateModified\":\"2019-11-28T12:11:47+00:00\",\"description\":\"Flutter is a minimal node module designed to handle the Twitter API authentication flow, and also has helper methods for making authenticated requests.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.gosquared.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Introducing Flutter\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#webpage\"},\"author\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/bfcd35bf2eba92ecbeea67937cd23eef\"},\"headline\":\"Introducing Flutter\",\"datePublished\":\"2014-04-10T15:52:27+00:00\",\"dateModified\":\"2019-11-28T12:11:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#webpage\"},\"wordCount\":250,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#primaryimage\"},\"thumbnailUrl\":\"https:\/\/static.gosquared.com\/images\/liquidicity\/14_04_09_flutter_01.png\",\"articleSection\":[\"Engineering\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/bfcd35bf2eba92ecbeea67937cd23eef\",\"name\":\"JT\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/772e026206b900a5ba17ebbe63e34a4c8a9103524cf0ba3accfa38b14d7d03ba?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/772e026206b900a5ba17ebbe63e34a4c8a9103524cf0ba3accfa38b14d7d03ba?s=96&d=mm&r=g\",\"caption\":\"JT\"},\"description\":\"JT is a co-founder and the lead front-end engineer at GoSquared. He's responsible for the shiniest of the shiny projects we work on.\",\"sameAs\":[\"https:\/\/twitter.com\/floopily\"],\"url\":\"https:\/\/www.gosquared.com\/blog\/author\/jt\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Introducing Flutter - GoSquared Blog","description":"Flutter is a minimal node module designed to handle the Twitter API authentication flow, and also has helper methods for making authenticated requests.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth","og_locale":"en_US","og_type":"article","og_title":"Introducing Flutter","og_description":"Flutter is a minimal node module designed to handle the Twitter API authentication flow, and also has helper methods for making authenticated requests.","og_url":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth","og_site_name":"GoSquared Blog","article_publisher":"https:\/\/www.facebook.com\/GoSquared","article_published_time":"2014-04-10T15:52:27+00:00","article_modified_time":"2019-11-28T12:11:47+00:00","og_image":[{"url":"https:\/\/static.gosquared.com\/images\/liquidicity\/14_04_09_flutter_01.png"}],"twitter_card":"summary_large_image","twitter_creator":"@floopily","twitter_site":"@GoSquared","twitter_misc":{"Written by":"JT","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/www.gosquared.com\/blog\/#organization","name":"GoSquared","url":"https:\/\/www.gosquared.com\/blog\/","sameAs":["https:\/\/instagram.com\/gosquaredteam","https:\/\/www.linkedin.com\/company\/go-squared-ltd.","https:\/\/www.facebook.com\/GoSquared","https:\/\/twitter.com\/GoSquared"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png","contentUrl":"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png","width":1270,"height":250,"caption":"GoSquared"},"image":{"@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/www.gosquared.com\/blog\/#website","url":"https:\/\/www.gosquared.com\/blog\/","name":"GoSquared Blog","description":"Turn visitors into customers.","publisher":{"@id":"https:\/\/www.gosquared.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.gosquared.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#primaryimage","url":"https:\/\/static.gosquared.com\/images\/liquidicity\/14_04_09_flutter_01.png","contentUrl":"https:\/\/static.gosquared.com\/images\/liquidicity\/14_04_09_flutter_01.png"},{"@type":"WebPage","@id":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#webpage","url":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth","name":"Introducing Flutter - GoSquared Blog","isPartOf":{"@id":"https:\/\/www.gosquared.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#primaryimage"},"datePublished":"2014-04-10T15:52:27+00:00","dateModified":"2019-11-28T12:11:47+00:00","description":"Flutter is a minimal node module designed to handle the Twitter API authentication flow, and also has helper methods for making authenticated requests.","breadcrumb":{"@id":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.gosquared.com\/blog"},{"@type":"ListItem","position":2,"name":"Introducing Flutter"}]},{"@type":"Article","@id":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#article","isPartOf":{"@id":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#webpage"},"author":{"@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/bfcd35bf2eba92ecbeea67937cd23eef"},"headline":"Introducing Flutter","datePublished":"2014-04-10T15:52:27+00:00","dateModified":"2019-11-28T12:11:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#webpage"},"wordCount":250,"commentCount":0,"publisher":{"@id":"https:\/\/www.gosquared.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#primaryimage"},"thumbnailUrl":"https:\/\/static.gosquared.com\/images\/liquidicity\/14_04_09_flutter_01.png","articleSection":["Engineering"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.gosquared.com\/blog\/introducing-flutter-simple-twitter-api-auth#respond"]}]},{"@type":"Person","@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/bfcd35bf2eba92ecbeea67937cd23eef","name":"JT","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/772e026206b900a5ba17ebbe63e34a4c8a9103524cf0ba3accfa38b14d7d03ba?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/772e026206b900a5ba17ebbe63e34a4c8a9103524cf0ba3accfa38b14d7d03ba?s=96&d=mm&r=g","caption":"JT"},"description":"JT is a co-founder and the lead front-end engineer at GoSquared. He's responsible for the shiniest of the shiny projects we work on.","sameAs":["https:\/\/twitter.com\/floopily"],"url":"https:\/\/www.gosquared.com\/blog\/author\/jt"}]}},"wps_subtitle":"Making working with the Twitter API less hassle","_links":{"self":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/posts\/8354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/comments?post=8354"}],"version-history":[{"count":0,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/posts\/8354\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/media?parent=8354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/categories?post=8354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/tags?post=8354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}