{"id":570,"date":"2011-09-10T14:41:00","date_gmt":"2011-09-10T14:41:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/google-clientlogin-utility-in-java.html"},"modified":"2012-10-21T20:17:57","modified_gmt":"2012-10-21T20:17:57","slug":"google-clientlogin-utility-in-java","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html","title":{"rendered":"Google ClientLogin Utility in Java"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">Authentication and Authorization for Google APIs is a common feature in today\u2019s applications requiring integration and information exchange with Google services. While most of this Google authentication process is tailored for web applications, it is also available for desktop and installed applications. For Desktop applications Google recommends using an authentication method called <a href=\"http:\/\/code.google.com\/apis\/accounts\/docs\/AuthForInstalledApps.html\">ClientLogin<\/a>.<\/p>\n<p>It is worth to mention that ClientLogin is for use when there is a high level of trust between the application and the owner of the protected data. It is mostly commonly recommend for cases where the application owns the protected data.<\/p>\n<p>The ClientLogin method works mainly by sending HTTP Post requests to Google service using specific parameters as described in <a href=\"http:\/\/code.google.com\/apis\/accounts\/docs\/AuthForInstalledApps.html\">Google documentation<\/a>. In this article we will use a different approach to implement ClientLogin authorization process. We will use <a href=\"http:\/\/code.google.com\/p\/google-api-java-client\/\">Google APIs Client Library for Java<\/a>, which is a powerful java library for accessing Google\u2019s HTTP-based API\u2019s on the web. The most important class in this library is, obviously, the <a href=\"http:\/\/code.google.com\/p\/google-api-java-client\/source\/browse\/google-api-client\/src\/main\/java\/com\/google\/api\/client\/googleapis\/auth\/clientlogin\/ClientLogin.java\">ClientLogin<\/a> class.<\/p>\n<p><strong>1-Anatomy of the ClientLogin class:<\/strong><\/p>\n<p>ClientLogin class provides a single method authenticate() which handles the details of authentication process. it also provides an important internal class ErrorInfo which could be used to handle authentication errors and captcha challenge logic.<\/p>\n<p>In this post we present a clean wrapper class for ClientLogin which handles the complete ClientLogin authorization process including authentication errors parsing and captcha challenge handling.<\/p>\n<p><strong>2-google-api-java-client Maven Dependencies:<\/strong><\/p>\n<p>We chose to use maven for building our project example. Maven provides dependencies for the Google APIs Client Library for Java. just add the following maven dependencies to your pom.xml file:<\/p>\n<pre class=\"brush:xml\">&lt;dependency&gt;\r\n\t&lt;groupId&gt;com.google.api.client&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;google-api-client-googleapis-auth-clientlogin&lt;\/artifactId&gt;\r\n\t&lt;version&gt;1.2.3-alpha&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n&lt;dependency&gt;\r\n\t&lt;groupId&gt;com.google.api.client&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;google-api-client-javanet&lt;\/artifactId&gt;\r\n\t&lt;version&gt;1.2.3-alpha&lt;\/version&gt;\r\n&lt;\/dependency&gt;\r\n<\/pre>\n<p>After that use maven:install to install the required jars to be included in our project classpath.<\/p>\n<p><strong>3-GoogleClientLogin wrapper class:<\/strong><\/p>\n<p>Our wrapper class obviously contains a reference to ClientLogin . It provides public methods implementing the important functions of the authentication process.<\/p>\n<p>GoogleClientLogin has a constructor that takes a String representing the Google service you\u2019re requesting authorization for (for example \u201ccl\u201d for Google Calendar). The constructor looks like this:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java\">\/**\r\n* @param service\r\n*\/\r\npublic GoogleClientLogin(String service) {\r\n\tsuper();\r\n\tthis.service = service;\r\n\tauthenticator = new ClientLogin();\r\n\ttransport = GoogleTransport.create();\r\n\tauthenticator.authTokenType = service;\r\n}\r\n<\/pre>\n<p>The main method is authenticate(username,password) that takes two arguments representing the username and password input by user:<\/p>\n<pre class=\"brush:java\">\/**\r\n* @param username\r\n* @param password\r\n* @throws ClientLoginException\r\n*\/\r\npublic void authenticate(String username, String password)\r\n\t\tthrows ClientLoginException {\r\n\r\n\ttry {\r\n\r\n\t\t\/\/ authenticate with ClientLogin\r\n\t\tauthenticator.username = username;\r\n\t\tauthenticator.password = password;\r\n\t\tResponse response = authenticator.authenticate();\r\n\t\tthis.authToken = response.auth;\r\n\r\n\t} catch (HttpResponseException e) {\r\n\t\tparseError(e);\r\n\r\n\t} catch (IOException e) {\r\n\t\t\/\/ TODO Auto-generated catch block\r\n\t\te.printStackTrace();\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>This method sets ClientLogin variables (username and password) then calls ClientLogin.authenticate() which returns a Response instance. if the ClientLogin.authenticate() call is successful we store the Authentication token \u2018Response.auth\u2019. The advantage of the authenticate(username,password) wrapper method is its intelligent handling of authentication errors.<\/p>\n<p><strong>Parsing Authentication errors:<\/strong><\/p>\n<p>We distinguish two Error categories that could be thrown during the call to Clientlogin.authenticate():<\/p>\n<p>a-unrecoverable Errors for which we use a ClientLoginException class<br \/>\nb-a recoverable error thrown when Google service requires a captcha challenge.<\/p>\n<p>For this later we use a separate Exception class CaptchaRequiredException which extends the first ClientLoginException class.<\/p>\n<p>Clientlogin.authenticate() throws a HttpResponseException if the authentication response has an error code. we provide a helper method for parsing this exception class as follows:<\/p>\n<pre class=\"brush:java\">\/**\r\n * @param e\r\n * @throws ClientLoginException\r\n *\/\r\nprivate void parseError(HttpResponseException e)\r\n\t\tthrows ClientLoginException {\r\n\ttry {\r\n\r\n\t\tClientLogin.ErrorInfo errorInfo = e.response.parseAs(ClientLogin.ErrorInfo.class);\r\n\t\terrorMessage = errorMsg.get(errorInfo.error);\r\n\t\tif (errorInfo.error.equals(CaptchaRequired)) {\r\n\t\t\tcaptchaToken = errorInfo.captchaToken;\r\n\t\t\tcaptchaUrl = errorInfo.captchaUrl;\r\n\t\t\tthrow new CaptchaRequiredException(errorMessage, e);\r\n\r\n\t\t} else\r\n\t\t\tthrow new ClientLoginException(errorMessage, e);\r\n\t} catch (IOException e1) {\r\n\r\n\t\tthrow new ClientLoginException(e1);\r\n\t}\r\n}\r\n<\/pre>\n<p>We Call HttpResponseException.response.parseAs(ClientLogin.ErrorInfo.class) to parse the response. If the error code is \u201cCaptchaRequired\u201d, we store errorInfo.captchaToken and errorInfo.captchaUrl then throw CaptchaRequiredException. For the rest of Error codes we just throw ClientLoginException.<\/p>\n<p><strong>Authentication with CAPTCHA Challenge<\/strong><\/p>\n<p>In the case of a CAPTCHA challenge we provide a second authenticate() method which provides an extra argument \u2018captchaAnswer\u2019 representing the captcha key entered by user during a CAPTCHA challenge:<\/p>\n<pre class=\"brush:java\">\/**\r\n * @param username\r\n * @param password\r\n * @param captchaAnswer\r\n * @throws ClientLoginException\r\n *\/\r\npublic void authenticate(String username, String password,\r\n\t\tString captchaAnswer) throws ClientLoginException {\r\n\tauthenticator.username = username;\r\n\tauthenticator.password = password;\r\n\tauthenticator.captchaToken = this.captchaToken;\r\n\tauthenticator.captchaAnswer = captchaAnswer;\r\n\ttry {\r\n\t\tResponse response = authenticator.authenticate();\r\n\t\tthis.authToken = response.auth;\r\n\t} catch (HttpResponseException e) {\r\n\t\tparseError(e);\r\n\t} catch (IOException e) {\r\n\t\tthrow new ClientLoginException(e);\r\n\t}\r\n}\r\n<\/pre>\n<p>Before calling authenticator.authenticate() this method sets two extra fields authenticator.captchaToken and authenticator.captchaAnswer. Error handling for this method is the same as the main authenticate(username,password) method.<\/p>\n<p>Finally we provide a method to retrieve the CAPTCHA image that will be displayed to user:<\/p>\n<pre class=\"brush:java\">\/**\r\n * @return the captchaImage\r\n *\/\r\npublic BufferedImage getCaptchaImage() {\r\n\r\n\tBufferedImage image = null;\r\n\ttry {\r\n\t\tURL url = new URL(\"https:\/\/www.google.com\/accounts\/\"+ getCaptchaUrl());\r\n\t\timage = ImageIO.read(url);\r\n\t} catch (MalformedURLException e) {\r\n\t\t\/\/ TODO Auto-generated catch block\r\n\t\te.printStackTrace();\r\n\t\treturn null;\r\n\r\n\t} catch (IOException e) {\r\n\t\t\/\/ TODO Auto-generated catch block\r\n\t\te.printStackTrace();\r\n\t\treturn null;\r\n\t}\r\n\r\n\treturn image;\r\n}\r\n<\/pre>\n<p>You can view the complete GoogleClientLogin class source file <a href=\"http:\/\/code.google.com\/p\/google-apis-utils\/source\/browse\/trunk\/Google-API-Utils\/src\/main\/java\/com\/google\/clientlogin\/GoogleClientLogin.java\">here<\/a>.<\/p>\n<p><strong>4-Testing GoogleClient wrapper class<\/strong><\/p>\n<p><a href=\"http:\/\/code.google.com\/p\/google-apis-utils\/source\/browse\/trunk\/Google-API-Utils\/src\/main\/java\/com\/google\/clientlogin\/example\/ClientLoginDialog.java\">GoogleClientLoginDialog<\/a> is a swing Dialog which presents an example of how to use <a href=\"http:\/\/code.google.com\/p\/google-apis-utils\/source\/browse\/trunk\/Google-API-Utils\/src\/main\/java\/com\/google\/clientlogin\/GoogleClientLogin.java\">GoogleClientLogin<\/a> wrapper class. It provides a feature to force Google service to send a CAPTCHA challenge. we implement this test using a thread that keeps sending random passwords until Google responds with a CAPTCHA challenge:<\/p>\n<pre class=\"brush:java\">private class ForceCaptchaRunnable implements Runnable{\r\n\r\n\tpublic void run() {\r\n\t\tRandom r = new Random();\r\n\t\tboolean isCaptcha = false;\r\n\t\twhile (!isCaptcha) {\r\n\t\t\ttry {\r\n\t\t\t\tclient.authenticate(textField.getText().trim(),\r\n\t\t\t\t\t\tpasswordField.getText().trim()+ r.nextInt(100));\r\n\t\t\t\tshowMessage(\"Auth Token: \"+client.getAuthToken());\r\n\t\t\t} catch (CaptchaRequiredException e1) {\r\n\r\n\t\t\t\tisCaptcha = true;\r\n\t\t\t\tshowCaptcha(true);\r\n\r\n\t\t\t} catch (ClientLoginException e1) {\r\n\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\r\n}\r\n<\/pre>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/--oKeKr6btZI\/TmtDpX5JdvI\/AAAAAAAAAGs\/99xGBEzWPs4\/s1600\/google-client-login-dialog.png\"><img decoding=\"async\" border=\"0\" height=\"214\" src=\"http:\/\/4.bp.blogspot.com\/--oKeKr6btZI\/TmtDpX5JdvI\/AAAAAAAAAGs\/99xGBEzWPs4\/s320\/google-client-login-dialog.png\" width=\"320\" \/><\/a><\/div>\n<p>You can view and download the complete source code of this sample project Google code project: <a href=\"http:\/\/code.google.com\/p\/google-apis-utils\/\">google-apis-utils<\/a>. <\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/othmanelmoulatblog.wordpress.com\/2011\/09\/02\/clientlogin-wrapper-using-google-apis-client-library-for-java\/\">Google ClientLogin Utility in Java<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Othman El Moulat at the <a href=\"http:\/\/othmanelmoulatblog.wordpress.com\/\">Othman&#8217;s blog<\/a>. <\/p>\n<p><strong><i>Related Articles :<\/i><\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/05\/getting-started-with-youtube-java-api.html\">Getting Started with YouTube Java API<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/09\/google-guava-libraries-essentials.html\">Google Guava Libraries Essentials<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/03\/java-code-geeks-andygene-web-archetype.html\">Java Code Geeks Andygene Web Archetype<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/12\/securing-gwt-apps-with-spring-security.html\">Securing GWT apps with Spring Security<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Authentication and Authorization for Google APIs is a common feature in today\u2019s applications requiring integration and information exchange with Google services. While most of this Google authentication process is tailored for web applications, it is also available for desktop and installed applications. For Desktop applications Google recommends using an authentication method called ClientLogin. It is &hellip;<\/p>\n","protected":false},"author":52,"featured_media":124,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[272],"class_list":["post-570","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-java","tag-google-clientlogin"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Google ClientLogin Utility in Java - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Authentication and Authorization for Google APIs is a common feature in today\u2019s applications requiring integration and information exchange with Google\" \/>\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.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Google ClientLogin Utility in Java - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Authentication and Authorization for Google APIs is a common feature in today\u2019s applications requiring integration and information exchange with Google\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2011-09-10T14:41:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T20:17:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-code-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Othman El Moulat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Othman El Moulat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html\"},\"author\":{\"name\":\"Othman El Moulat\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/d174bad5b633da585f1a82e92aafae9a\"},\"headline\":\"Google ClientLogin Utility in Java\",\"datePublished\":\"2011-09-10T14:41:00+00:00\",\"dateModified\":\"2012-10-21T20:17:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html\"},\"wordCount\":726,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-code-logo.jpg\",\"keywords\":[\"Google ClientLogin\"],\"articleSection\":[\"Core Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html\",\"name\":\"Google ClientLogin Utility in Java - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-code-logo.jpg\",\"datePublished\":\"2011-09-10T14:41:00+00:00\",\"dateModified\":\"2012-10-21T20:17:57+00:00\",\"description\":\"Authentication and Authorization for Google APIs is a common feature in today\u2019s applications requiring integration and information exchange with Google\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-code-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-code-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/google-clientlogin-utility-in-java.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/core-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Google ClientLogin Utility in Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/d174bad5b633da585f1a82e92aafae9a\",\"name\":\"Othman El Moulat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d0f5fa9b4298921705ec794411baff845e51d6c1a570d671a238937eecf05627?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d0f5fa9b4298921705ec794411baff845e51d6c1a570d671a238937eecf05627?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d0f5fa9b4298921705ec794411baff845e51d6c1a570d671a238937eecf05627?s=96&d=mm&r=g\",\"caption\":\"Othman El Moulat\"},\"sameAs\":[\"http:\\\/\\\/othmanelmoulatblog.wordpress.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Othman-El-Moulat\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Google ClientLogin Utility in Java - Java Code Geeks","description":"Authentication and Authorization for Google APIs is a common feature in today\u2019s applications requiring integration and information exchange with Google","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.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html","og_locale":"en_US","og_type":"article","og_title":"Google ClientLogin Utility in Java - Java Code Geeks","og_description":"Authentication and Authorization for Google APIs is a common feature in today\u2019s applications requiring integration and information exchange with Google","og_url":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-09-10T14:41:00+00:00","article_modified_time":"2012-10-21T20:17:57+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-code-logo.jpg","type":"image\/jpeg"}],"author":"Othman El Moulat","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Othman El Moulat","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html"},"author":{"name":"Othman El Moulat","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/d174bad5b633da585f1a82e92aafae9a"},"headline":"Google ClientLogin Utility in Java","datePublished":"2011-09-10T14:41:00+00:00","dateModified":"2012-10-21T20:17:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html"},"wordCount":726,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-code-logo.jpg","keywords":["Google ClientLogin"],"articleSection":["Core Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html","url":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html","name":"Google ClientLogin Utility in Java - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-code-logo.jpg","datePublished":"2011-09-10T14:41:00+00:00","dateModified":"2012-10-21T20:17:57+00:00","description":"Authentication and Authorization for Google APIs is a common feature in today\u2019s applications requiring integration and information exchange with Google","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-code-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-code-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/google-clientlogin-utility-in-java.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/core-java"},{"@type":"ListItem","position":4,"name":"Google ClientLogin Utility in Java"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/d174bad5b633da585f1a82e92aafae9a","name":"Othman El Moulat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d0f5fa9b4298921705ec794411baff845e51d6c1a570d671a238937eecf05627?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d0f5fa9b4298921705ec794411baff845e51d6c1a570d671a238937eecf05627?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d0f5fa9b4298921705ec794411baff845e51d6c1a570d671a238937eecf05627?s=96&d=mm&r=g","caption":"Othman El Moulat"},"sameAs":["http:\/\/othmanelmoulatblog.wordpress.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Othman-El-Moulat"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=570"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/570\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/124"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}