{"id":6305,"date":"2012-08-24T16:12:56","date_gmt":"2012-08-24T10:42:56","guid":{"rendered":"https:\/\/tothenewco.pro\/blog\/?p=6305"},"modified":"2017-02-06T10:40:25","modified_gmt":"2017-02-06T05:10:25","slug":"login-with-twitter","status":"publish","type":"post","link":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/","title":{"rendered":"Login with Twitter"},"content":{"rendered":"<p>This application saves user\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account.<\/p>\n<h5>Five simple steps to connect with twitter<\/h5>\n<p><strong>1. <\/strong>First of all, you have to <a href=\"https:\/\/dev.twitter.com\/apps\">register<\/a> your application with twitter. Once the application is registered you will receive <strong>\u201cconsumer key\u201d<\/strong> and <strong>\u201cconsumer secret\u201d<\/strong>.<\/p>\n<p><strong>2.<\/strong> Write <strong>\u201cconsumer key\u201d<\/strong> and <strong>\u201cconsumer secret\u201d<\/strong> in <strong>Config.groovy<\/strong> as:<\/p>\n<p>[groovy]<br \/>\ntwitter {<br \/>\n    oauth.consumer_key = &#8216;mjnSnJAtlpI0TTriR4gQ&#8217;<br \/>\n    oauth.consumer_secret = &#8217;86IEve8R37TNAIoSFoGPlMxbPCHpvvmFr2eAwwU&#8217;<br \/>\n}<br \/>\n[\/groovy]<\/p>\n<p><strong>3.<\/strong> To provide <strong>twitter<\/strong> utility into <strong>grails<\/strong> app, add dependance into <strong>BuildConfig.groovy<\/strong> as:<\/p>\n<p>[groovy]<br \/>\nbuild &#8216;net.homeip.yusuke:twitter4j:2.0.10&#8217;<br \/>\n[\/groovy]<\/p>\n<p><strong>Twitter<\/strong> provide <strong>twitter4j<\/strong> named API to intract with twitter.<\/p>\n<p><strong>4.<\/strong> Create a link which says to <strong>login with twitter<\/strong> as:<\/p>\n<p>[groovy]<br \/>\nLogin with Twitter<br \/>\n[\/groovy]<\/p>\n<p><strong>5.<\/strong> Create <strong>LoginController<\/strong> with <strong>actionName<\/strong> as <strong>loginWithTwitter<\/strong>:<\/p>\n<p>[groovy]<br \/>\nimport org.codehaus.groovy.grails.commons.ConfigurationHolder<\/p>\n<p>class LoginController {<\/p>\n<p>    def requestLogin() {<br \/>\n        def twitter = new twitter4j.Twitter()<br \/>\n        def callbackUrl = g.createLink(action: &#8216;processLogin&#8217;, absolute:true).toString()<br \/>\n        def consumerKey = ConfigurationHolder.config.twitter.oauth.consumer_key<br \/>\n        def consumerSecret = ConfigurationHolder.config.twitter.oauth.consumer_secret<br \/>\n        twitter.setOAuthConsumer(consumerKey, consumerSecret)<br \/>\n        def requestToken = twitter.getOAuthRequestToken(callbackUrl)<br \/>\n        session.twitter = twitter<br \/>\n        session.requestToken = requestToken<br \/>\n        redirect(url:requestToken.getAuthorizationURL())<br \/>\n    }<\/p>\n<p>    def processLogin() {<br \/>\n        if (!session.requestToken) {<br \/>\n            redirect(action: &#8216;requestLogin&#8217;)<br \/>\n        } else {<br \/>\n            def accessToken = session.twitter.getOAuthAccessToken(session.requestToken, params.oauth_verifier)<br \/>\n            def twitterUser = session.twitter.verifyCredentials()<br \/>\n            session.twitterUser = twitterUser<br \/>\n            redirect(action: &#8216;dashboard&#8217;)<br \/>\n        }<br \/>\n    }<br \/>\n}<br \/>\n[\/groovy]<\/p>\n<p>When user click on Login with Twitter link, requestLogin action is called which redirects request to twitter for authorization. On successful authorization from twitter, user will be redirected to call back url (on processLogin Action). processLogin Action gets all the information related to user (in twitterUser object) from twitter. Registration can be done for that user with that twitter information, and user can then access the application through his twitter account information.<\/p>\n<p><strong><a href=\"https:\/\/tothenewco.pro\/blog\/author\/amit-kumar\/\">More Blogs by Me<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This application saves user\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account. Five simple steps to connect with [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":9,"footnotes":""},"categories":[7],"tags":[4840,878,873],"class_list":["post-6305","post","type-post","status-publish","format-standard","hentry","category-grails","tag-grails","tag-login","tag-twitter"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"This application saves user\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account. Five simple steps to connect with\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Amit Kumar\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Login with Twitter | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"This application saves user\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account. Five simple steps to connect with\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Login with Twitter | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"This application saves user\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account. Five simple steps to connect with\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/#article\",\"name\":\"Login with Twitter | TO THE NEW Blog\",\"headline\":\"Login with Twitter\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit-kumar\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2012-08-24T16:12:56+05:30\",\"dateModified\":\"2017-02-06T10:40:25+05:30\",\"inLanguage\":\"en-US\",\"commentCount\":2,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/#webpage\"},\"articleSection\":\"Grails, Grails, login, twitter\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"position\":2,\"name\":\"Grails\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/#listItem\",\"name\":\"Login with Twitter\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/#listItem\",\"position\":3,\"name\":\"Login with Twitter\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit-kumar\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit-kumar\\\/\",\"name\":\"Amit Kumar\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/859356966acd3c3879759369c7ac72cfb81228287bfc78e99c3080bee9b6b9ba?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Amit Kumar\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/\",\"name\":\"Login with Twitter | TO THE NEW Blog\",\"description\":\"This application saves user\\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account. Five simple steps to connect with\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/login-with-twitter\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit-kumar\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit-kumar\\\/#author\"},\"datePublished\":\"2012-08-24T16:12:56+05:30\",\"dateModified\":\"2017-02-06T10:40:25+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Login with Twitter | TO THE NEW Blog","description":"This application saves user\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account. Five simple steps to connect with","canonical_url":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/#article","name":"Login with Twitter | TO THE NEW Blog","headline":"Login with Twitter","author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/amit-kumar\/#author"},"publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"},"datePublished":"2012-08-24T16:12:56+05:30","dateModified":"2017-02-06T10:40:25+05:30","inLanguage":"en-US","commentCount":2,"mainEntityOfPage":{"@id":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/#webpage"},"isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/#webpage"},"articleSection":"Grails, Grails, login, twitter"},{"@type":"BreadcrumbList","@id":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/tothenewco.pro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/grails\/#listItem","name":"Grails"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/grails\/#listItem","position":2,"name":"Grails","item":"https:\/\/tothenewco.pro\/blog\/category\/grails\/","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/#listItem","name":"Login with Twitter"},"previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/#listItem","position":3,"name":"Login with Twitter","previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/grails\/#listItem","name":"Grails"}}]},{"@type":"Organization","@id":"https:\/\/tothenewco.pro\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/tothenewco.pro\/blog\/"},{"@type":"Person","@id":"https:\/\/tothenewco.pro\/blog\/author\/amit-kumar\/#author","url":"https:\/\/tothenewco.pro\/blog\/author\/amit-kumar\/","name":"Amit Kumar","image":{"@type":"ImageObject","@id":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/859356966acd3c3879759369c7ac72cfb81228287bfc78e99c3080bee9b6b9ba?s=96&d=mm&r=g","width":96,"height":96,"caption":"Amit Kumar"}},{"@type":"WebPage","@id":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/#webpage","url":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/","name":"Login with Twitter | TO THE NEW Blog","description":"This application saves user\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account. Five simple steps to connect with","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/#breadcrumblist"},"author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/amit-kumar\/#author"},"creator":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/amit-kumar\/#author"},"datePublished":"2012-08-24T16:12:56+05:30","dateModified":"2017-02-06T10:40:25+05:30"},{"@type":"WebSite","@id":"https:\/\/tothenewco.pro\/blog\/#website","url":"https:\/\/tothenewco.pro\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Login with Twitter | TO THE NEW Blog","og:description":"This application saves user\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account. Five simple steps to connect with","og:url":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/","og:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Login with Twitter | TO THE NEW Blog","twitter:description":"This application saves user\u2019s time for registration by providing a way through which user can login into application with its twitter credentials. Application will get the user details from his corresponding twitter account and will do the registration programmatically, so user can easily manage account through his twitter account. Five simple steps to connect with","twitter:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"6305","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":"","og_description":"","og_object_type":"blog","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":"","og_article_tags":"","twitter_use_og":false,"twitter_card":"summary","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-30 06:19:09","updated":"2024-02-29 09:55:24","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\/category\/grails\/\" title=\"Grails\">Grails<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tLogin with Twitter\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/tothenewco.pro\/blog"},{"label":"Grails","link":"https:\/\/tothenewco.pro\/blog\/category\/grails\/"},{"label":"Login with Twitter","link":"https:\/\/tothenewco.pro\/blog\/login-with-twitter\/"}],"_links":{"self":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/6305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/comments?post=6305"}],"version-history":[{"count":0,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/6305\/revisions"}],"wp:attachment":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/media?parent=6305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/categories?post=6305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/tags?post=6305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}