List of usage examples for com.google.api.client.googleapis.auth.oauth2 GoogleOAuthConstants TOKEN_SERVER_URL
String TOKEN_SERVER_URL
To view the source code for com.google.api.client.googleapis.auth.oauth2 GoogleOAuthConstants TOKEN_SERVER_URL.
Click Source Link
From source file:ch.cyberduck.core.googledrive.DriveSession.java
License:Open Source License
@Override protected Drive connect(final HostKeyCallback callback) throws BackgroundException { this.transport = new ApacheHttpTransport(builder.build(this).build()); this.authorizationService = new OAuth2AuthorizationService(transport, GoogleOAuthConstants.TOKEN_SERVER_URL, GoogleOAuthConstants.AUTHORIZATION_SERVER_URL, preferences.getProperty("google.drive.client.id"), preferences.getProperty("google.drive.client.secret"), Collections.singletonList(DriveScopes.DRIVE)) .withLegacyPrefix(host.getProtocol().getDescription()); return new Drive.Builder(transport, json, new HttpRequestInitializer() { @Override/*w ww . j av a 2 s . c o m*/ public void initialize(HttpRequest request) throws IOException { request.setSuppressUserAgentSuffix(true); // Add bearer token to request credential.initialize(request); } }).setApplicationName(useragent.get()).build(); }
From source file:com.evolveum.polygon.connector.googleapps.GoogleAppsConfiguration.java
License:Open Source License
public GoogleCredential getGoogleCredential() { if (null == credential) { synchronized (this) { if (null == credential) { System.setProperty("https.protocols", "TLSv1.2"); credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY) .setTokenServerEncodedUrl(GoogleOAuthConstants.TOKEN_SERVER_URL) .setClientAuthentication(new ClientParametersAuthentication(getClientId(), SecurityUtil.decrypt(getClientSecret()))) .build();//from w ww.j a va 2 s .co m try { credential.setRefreshToken(SecurityUtil.decrypt(getRefreshToken())).refreshToken(); } catch (IOException ex) { logger.error("Token refresh error: {0}", ex.getMessage()); } getRefreshToken().access(new GuardedString.Accessor() { @Override public void access(char[] chars) { credential.setRefreshToken(new String(chars)); } }); directory = new Directory.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential) .setApplicationName("GoogleAppsConnector").build(); licensing = new Licensing.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential) .setApplicationName("GoogleAppsConnector").build(); groupsSettings = new Groupssettings.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential) .setApplicationName("GoogleAppsConnector").build(); try { //credential.refreshToken(); auditService = new AuditService(getDomain(), getAppName()); auditService.setOAuth2Credentials(credential); } catch (AuthenticationException ex) { Logger.getLogger(GoogleAppsConfiguration.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException(ex); } } } } return credential; }
From source file:com.google.cloud.dataflow.sdk.options.GcpOptions.java
License:Apache License
/** * The token server URL to use for OAuth 2 authentication. Normally, the default is sufficient, * but some specialized use cases may want to override this value. *///ww w. j a v a 2s . com @Description("The token server URL to use for OAuth 2 authentication. Normally, the default " + "is sufficient, but some specialized use cases may want to override this value.") @Default.String(GoogleOAuthConstants.TOKEN_SERVER_URL) @Hidden String getTokenServerUrl();
From source file:com.googlecodesamples.FusionTablesAccessor.java
License:Apache License
private static Credential.Builder newCredentialBuilder(final OAuth2Tokens tokens) { return new Credential.Builder(BearerToken.authorizationHeaderAccessMethod()).setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY).setClientAuthentication(NOOP_CLIENT_AUTHENTICATION) .setRefreshListeners(Collections.<CredentialRefreshListener>singleton(tokens)) .setTokenServerEncodedUrl(GoogleOAuthConstants.TOKEN_SERVER_URL); }
From source file:com.threepillar.labs.meeting.google.GoogleInviteImpl.java
License:Open Source License
private void createClient() { Credential.Builder builder = new Credential.Builder(BearerToken.authorizationHeaderAccessMethod()); builder.setJsonFactory(JSON_FACTORY).setTransport(HTTP_TRANSPORT); ClientParametersAuthentication auth = new ClientParametersAuthentication(properties.getProperty(CLIENT_ID), properties.getProperty(CLIENT_SECRET)); builder.setRequestInitializer(auth); builder.setClientAuthentication(auth); builder.setTokenServerUrl(new GenericUrl(GoogleOAuthConstants.TOKEN_SERVER_URL)); builder.setTokenServerEncodedUrl(GoogleOAuthConstants.TOKEN_SERVER_URL); Credential cr = builder.build();/*from w w w .jav a 2s. c om*/ cr.setAccessToken(properties.getProperty(ACCESS_TOKEN)); cr.setRefreshToken(properties.getProperty(REFRESH_TOKEN)); System.out.println(System.currentTimeMillis()); cr.setExpirationTimeMilliseconds(new Long(properties.getProperty(EXPIRY_TIME_IN_MILLIS))); // set up global Calendar instance client = new com.google.api.services.calendar.Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, cr) .setApplicationName(APPLICATION_NAME).build(); }
From source file:net.tirasa.connid.bundles.googleapps.GoogleAppsConfiguration.java
License:Open Source License
public Credential getGoogleCredential() { synchronized (this) { if (null == credential) { credential = new Credential.Builder(BearerToken.authorizationHeaderAccessMethod()) .setTransport(HTTP_TRANSPORT).setJsonFactory(JSON_FACTORY) .setTokenServerEncodedUrl(GoogleOAuthConstants.TOKEN_SERVER_URL) .setClientAuthentication(new ClientParametersAuthentication(getClientId(), SecurityUtil.decrypt(getClientSecret()))) .build();//from w w w .j a v a2 s . c om getRefreshToken().access(new GuardedString.Accessor() { @Override public void access(char[] chars) { credential.setRefreshToken(new String(chars)); } }); directory = new Directory.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential) .setApplicationName("ConnId").build(); licensing = new Licensing.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential) .setApplicationName("ConnId").build(); } } return credential; }
From source file:org.forgerock.openicf.connectors.googleapps.GoogleAppsConfiguration.java
License:Open Source License
public Credential getGoogleCredential() { if (null == credential) { synchronized (this) { if (null == credential) { System.setProperty("https.protocols", "TLSv1.2"); credential = new Credential.Builder(BearerToken.authorizationHeaderAccessMethod()) .setTransport(HTTP_TRANSPORT).setJsonFactory(JSON_FACTORY) .setTokenServerEncodedUrl(GoogleOAuthConstants.TOKEN_SERVER_URL) .setClientAuthentication(new ClientParametersAuthentication(getClientId(), SecurityUtil.decrypt(getClientSecret()))) .build();/*from w ww . j a v a2s. c om*/ try { credential.setRefreshToken(SecurityUtil.decrypt(getRefreshToken())).refreshToken(); } catch (IOException ex) { logger.error("Token refresh error: ", ex); } getRefreshToken().access(new GuardedString.Accessor() { @Override public void access(char[] chars) { credential.setRefreshToken(new String(chars)); } }); directory = new Directory.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential) .setApplicationName("GoogleAppsConnector").build(); licensing = new Licensing.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential) .setApplicationName("GoogleAppsConnector").build(); } } } return credential; }