Source:
<code>public static void main( String[] args) throws Exception { if (System.getenv("ASANA_CLIENT_ID") == null || System.getenv("ASANA_CLIENT_SECRET") == null) { throw new Error("Please set the ASANA_CLIENT_ID and ASANA_CLIENT_SECRET environment variables."); } System.out.println("== Example using OAuth Client ID and Client Secret:"); OAuthApp app = new OAuthApp( System.getenv("ASANA_CLIENT_ID"), System.getenv("ASANA_CLIENT_SECRET"), OAuthApp.NATIVE_REDIRECT_URI ); Client client = Client.oauth(app); System.out.println("isAuthorized=" + app.isAuthorized()); String url = app.getAuthorizationUrl("FIXME: random state"); System.out.println(url); Desktop.getDesktop().browse(new URI(url)); System.out.println("Copy and paste the returned code from the browser and press enter:"); String code = new LineReader(new InputStreamReader(System.in)).readLine(); String accessToken = app.fetchToken(code); System.out.println("isAuthorized=" + app.isAuthorized()); System.out.println("token=" + accessToken); User user = client.users.me().execute(); System.out.println("me=" + user.name); System.out.println(user.id); <START> if (user.photo != null) <END> System.out.println(user.photo.image_128x128); System.out.println(user.workspaces.iterator().next().name); System.out.println("== Example using OAuth Access Token:"); app = new OAuthApp( System.getenv("ASANA_CLIENT_ID"), System.getenv("ASANA_CLIENT_SECRET"), "urn:ietf:wg:oauth:2.0:oob", accessToken ); client = Client.oauth(app); System.out.println("isAuthorized=" + app.isAuthorized()); System.out.println("me=" + client.users.me().execute().name); }</code><technical_language>try avoid no-braces form of if-statements</technical_language>

Target:
public static void main( String[] args) throws Exception { if (System.getenv("ASANA_CLIENT_ID") == null || System.getenv("ASANA_CLIENT_SECRET") == null) { throw new Error("Please set the ASANA_CLIENT_ID and ASANA_CLIENT_SECRET environment variables."); } System.out.println("== Example using OAuth Client ID and Client Secret:"); OAuthApp app = new OAuthApp( System.getenv("ASANA_CLIENT_ID"), System.getenv("ASANA_CLIENT_SECRET"), OAuthApp.NATIVE_REDIRECT_URI ); Client client = Client.oauth(app); System.out.println("isAuthorized=" + app.isAuthorized()); String url = app.getAuthorizationUrl("FIXME: random state"); System.out.println(url); Desktop.getDesktop().browse(new URI(url)); System.out.println("Copy and paste the returned code from the browser and press enter:"); String code = new LineReader(new InputStreamReader(System.in)).readLine(); String accessToken = app.fetchToken(code); System.out.println("isAuthorized=" + app.isAuthorized()); System.out.println("token=" + accessToken); User user = client.users.me().execute(); System.out.println("me=" + user.name); System.out.println(user.id); if (user.photo != null) { System.out.println(user.photo.image_128x128); } System.out.println(user.workspaces.iterator().next().name); System.out.println("== Example using OAuth Access Token:"); app = new OAuthApp( System.getenv("ASANA_CLIENT_ID"), System.getenv("ASANA_CLIENT_SECRET"), "urn:ietf:wg:oauth:2.0:oob", accessToken ); client = Client.oauth(app); System.out.println("isAuthorized=" + app.isAuthorized()); System.out.println("me=" + client.users.me().execute().name); }