com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl Java Examples

The following examples show how to use com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GuiMain.java    From google-sites-liberation with Apache License 2.0 5 votes vote down vote up
private void openBrowserAndGetToken() {
  // Step 1: Authorize -->
  String authorizationUrl = new GoogleAuthorizationCodeRequestUrl(
      CLIENT_ID, REDIRECT_URI, SCOPES).build();
  try {
    // Point or redirect your user to the authorizationUrl.
    java.awt.Desktop.getDesktop().browse(new URI(authorizationUrl));
  } catch (Exception e) {
    LOGGER.warning("Unable to open browser: " + e.toString());
    LOGGER.info("Go to: " + authorizationUrl);
    JOptionPane.showMessageDialog(optionsFrame, "Cannot open browser. Check the console for the necessary URL.",
                                  "Error", JOptionPane.ERROR_MESSAGE);
  }
  // End of Step 1 <--
}
 
Example #2
Source File: CredentialManager.java    From drivemarks with Apache License 2.0 5 votes vote down vote up
/**
 * Generates a consent page url.
 * @return A consent page url string for user redirection.
 */
public String getAuthorizationUrl() {
  GoogleAuthorizationCodeRequestUrl urlBuilder =
      new GoogleAuthorizationCodeRequestUrl(
      clientSecrets.getWeb().getClientId(),
      clientSecrets.getWeb().getRedirectUris().get(0), SCOPES);;
 return urlBuilder.build();
}
 
Example #3
Source File: LoginServiceUi.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public String obtainVerificationCodeFromUserInteraction(
    String title, GoogleAuthorizationCodeRequestUrl authCodeRequestUrl) {
  throw new RuntimeException("Not to be called."); //$NON-NLS-1$
}
 
Example #4
Source File: GoogleLoginService.java    From google-cloud-eclipse with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a URL through which users can login.
 *
 * @param redirectUrl URL to which the login result is directed. For example, a local web
 *     server listening on the URL can receive an authorization code from it.
 */
public static String getGoogleLoginUrl(String redirectUrl) {
  return new GoogleAuthorizationCodeRequestUrl(Constants.getOAuthClientId(), redirectUrl,
      OAUTH_SCOPES).toString();
}