Handles user authorization by redirecting to the OAuth 2.0 authorization server.
Default implementation is to call browse(authorizationUrl.build()). Subclasses may
override to provide optional parameters such as the recommended state parameter. Sample
implementation:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Class AuthorizationCodeInstalledApp (1.39.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.39.0 (latest)](/java/docs/reference/google-oauth-client/latest/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)\n- [1.38.2](/java/docs/reference/google-oauth-client/1.38.2/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)\n- [1.37.0](/java/docs/reference/google-oauth-client/1.37.0/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)\n- [1.36.0](/java/docs/reference/google-oauth-client/1.36.0/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)\n- [1.34.1](/java/docs/reference/google-oauth-client/1.34.1/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)\n- [1.33.3](/java/docs/reference/google-oauth-client/1.33.3/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)\n- [1.32.1](/java/docs/reference/google-oauth-client/1.32.1/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp) \n\n public class AuthorizationCodeInstalledApp\n\nOAuth 2.0 authorization code flow for an installed Java application that persists end-user\ncredentials.\n\nImplementation is thread-safe. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e AuthorizationCodeInstalledApp \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Methods\n--------------\n\n### browse(String url)\n\n public static void browse(String url)\n\nOpen a browser at the given URL using Desktop if available, or alternatively output the\nURL to System#out for command-line applications.\n\nConstructors\n------------\n\n### AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow, VerificationCodeReceiver receiver)\n\n public AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow, VerificationCodeReceiver receiver)\n\n### AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow, VerificationCodeReceiver receiver, AuthorizationCodeInstalledApp.Browser browser)\n\n public AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow, VerificationCodeReceiver receiver, AuthorizationCodeInstalledApp.Browser browser)\n\nMethods\n-------\n\n### authorize(String userId)\n\n public Credential authorize(String userId)\n\nAuthorizes the installed application to access user's protected data.\n\n### getFlow()\n\n public final AuthorizationCodeFlow getFlow()\n\nReturns the authorization code flow.\n\n### getReceiver()\n\n public final VerificationCodeReceiver getReceiver()\n\nReturns the verification code receiver.\n\n### onAuthorization(AuthorizationCodeRequestUrl authorizationUrl)\n\n protected void onAuthorization(AuthorizationCodeRequestUrl authorizationUrl)\n\nHandles user authorization by redirecting to the OAuth 2.0 authorization server.\n\nDefault implementation is to call `browse(authorizationUrl.build())`. Subclasses may\noverride to provide optional parameters such as the recommended state parameter. Sample\nimplementation:\n\n@Override\nprotected void onAuthorization(AuthorizationCodeRequestUrl authorizationUrl) throws IOException {\nauthorizationUrl.setState(\"xyz\");\nsuper.onAuthorization(authorizationUrl);\n}"]]