code: public Credential authenticate(String authorizationCode, String userId) throws AuthException {
          Preconditions.checkNotNull(authorizationCode, "Authorization code must not be null");
          AuthorizationCodeTokenRequest tokenRequest = authorizationCodeFlow.newTokenRequest(authorizationCode);
  
          TokenResponse tokenResponse;
          try {
              tokenResponse = tokenRequest
                      .setRedirectUri(redirectUri)
                      .setScopes(scopes)
                      .execute();
          } catch (IOException e) {
              throw new AuthException("Unable to request token.", e);
          }
          try {
              return authorizationCodeFlow.createAndStoreCredential(tokenResponse, userId);
          } catch (IOException e) {
              throw new AuthException("Unable to create and store credential.", e);
          }
      }
docs: Authenticates using the authorization code for the user and stores the Credential in the
  underlying {@link DataStore}.
  @throws AuthException If the credential could not be created.