OAuthUser user = new OAuthUser(); // Set clientId, clientSecret and email user.clientId = "<<clientID>>"; user.clientSecret = "<<clientSecret>>"; user.email = "<<email>>"; // You have to retrieve AuthorizationCode manually with generated AuthorizationCodeUrl // Set authorizationCode String authorizationCode = "<<authCode>>"; // Copy Code Verifier from the previous step output // Set codeVerifier String codeVerifier = "<<codeVerifier>>"; // Get Refresh Token String refreshToken = GoogleOAuthHelper.getAccessTokenByAuthCode(authorizationCode, codeVerifier, user); user.refreshToken = refreshToken; // Get Access Token String accessToken = GoogleOAuthHelper.getAccessTokenByRefreshToken(user); // Create Gmail client try (IGmailClient client = GmailClient.getInstance(accessToken, user.email)) { // Insert, get and update calendar Calendar calendar = new Calendar("Summary", "Description", "Location", "America/Los_Angeles"); // Insert calendar and Retrieve same calendar using id String id = client.createCalendar(calendar); }