com.google.api.client.json.jackson.JacksonFactory Java Examples
The following examples show how to use
com.google.api.client.json.jackson.JacksonFactory.
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: OAuthServlet.java From vpn-over-dns with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected AuthorizationCodeFlow initializeFlow() throws IOException { return new AuthorizationCodeFlow.Builder(BearerToken.authorizationHeaderAccessMethod(), new NetHttpTransport(), new JacksonFactory(), // token server URL: // new GenericUrl("https://server.example.com/token"), new GenericUrl("https://accounts.google.com/o/oauth2/auth"), new BasicAuthentication("458072371664.apps.googleusercontent.com", "mBp75wknGsGu0WMzHaHhqfXT"), "458072371664.apps.googleusercontent.com", // authorization server URL: "https://accounts.google.com/o/oauth2/auth"). // setCredentialStore(new JdoCredentialStore(JDOHelper.getPersistenceManagerFactory("transactions-optional"))) setCredentialStore(new MemoryCredentialStore()).setScopes("https://mail.google.com/") // setCredentialStore(new MyCredentialStore()) .build(); }
Example #2
Source File: OAuthServletCallback.java From vpn-over-dns with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected AuthorizationCodeFlow initializeFlow() throws IOException { return new AuthorizationCodeFlow.Builder(BearerToken.authorizationHeaderAccessMethod(), new NetHttpTransport(), new JacksonFactory(), // token server URL: // new GenericUrl("https://server.example.com/token"), new GenericUrl("https://accounts.google.com/o/oauth2/auth"), new BasicAuthentication("458072371664.apps.googleusercontent.com", "mBp75wknGsGu0WMzHaHhqfXT"), "458072371664.apps.googleusercontent.com", // authorization server URL: "https://accounts.google.com/o/oauth2/auth"). // setCredentialStore(new JdoCredentialStore(JDOHelper.getPersistenceManagerFactory("transactions-optional"))) setCredentialStore(new MemoryCredentialStore()).setScopes("https://mail.google.com/") // setCredentialStore(new MyCredentialStore()) .build(); }
Example #3
Source File: GoogleAuth.java From oncokb with GNU Affero General Public License v3.0 | 6 votes |
private static void createGoogleCredential() throws GeneralSecurityException, IOException { if (SERVICE_ACCOUNT_EMAIL == null) { SERVICE_ACCOUNT_EMAIL = PropertiesUtils.getProperties("google.service_account_email"); } if (SERVICE_ACCOUNT_PKCS12_FILE == null) { openFile(); } if (CREDENTIAL == null) { HttpTransport httpTransport = new NetHttpTransport(); JacksonFactory jsonFactory = new JacksonFactory(); String[] SCOPESArray = {"https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/gmail.compose"}; CREDENTIAL = new GoogleCredential.Builder() .setTransport(httpTransport) .setJsonFactory(jsonFactory) .setServiceAccountId(SERVICE_ACCOUNT_EMAIL) .setServiceAccountScopes(getScopes()) .setServiceAccountPrivateKeyFromP12File(SERVICE_ACCOUNT_PKCS12_FILE) .build(); } else { refreshToken(); } }
Example #4
Source File: JelectrumDBCloudData.java From jelectrum with MIT License | 6 votes |
private GoogleCredential openCredential() throws java.security.GeneralSecurityException, java.io.IOException { NetHttpTransport transport = GoogleNetHttpTransport.newTrustedTransport(); JacksonFactory jsonFactory = new JacksonFactory(); GoogleCredential cred = new GoogleCredential.Builder() .setTransport(transport) .setJsonFactory(jsonFactory) .setServiceAccountId(conf.get("google_api_account")) .setServiceAccountScopes(DatastoreOptions.SCOPES) .setServiceAccountPrivateKeyFromP12File(new File(conf.get("google_api_keyfile"))) .build(); return cred; }
Example #5
Source File: ApigeeDataClient.java From apigee-android-sdk with Apache License 2.0 | 6 votes |
/** * Used to get an OAuth 2 access_token using the password grant_type synchronously. * * @param accessTokenURL The accessTokenURL * @param username The username of the user to login * @param password The password of the user to login * @param clientId The clientId * @return The TokenResponse object if we successfully gathered the token or null if the attempt was not successful. */ public TokenResponse oauth2AccessToken(String accessTokenURL, String username, String password, String clientId) { validateNonEmptyParam(accessTokenURL, "accessTokenURL"); validateNonEmptyParam(username, "username"); validateNonEmptyParam(password, "password"); TokenResponse tokenResponse = null; // Make sure clientId is just non-null. Otherwise we will possibly crash or get an unneeded exception. if( clientId == null ) { clientId = ""; } try { AuthorizationRequestUrl authorizationRequestUrl = new AuthorizationRequestUrl(accessTokenURL, clientId, Collections.singleton("token")); PasswordTokenRequest passwordTokenRequest = new PasswordTokenRequest(new NetHttpTransport(), new JacksonFactory(), authorizationRequestUrl, username, password); tokenResponse = passwordTokenRequest.execute(); } catch (Exception exception) { } return tokenResponse; }
Example #6
Source File: ProjectRepositoryTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testHasAppengineApplication_noApplication() throws IOException, ProjectRepositoryException { Apps.Get get = initializeGetRequest(); GoogleJsonResponseException notFoundException = GoogleJsonResponseExceptionFactoryTesting.newMock(new JacksonFactory(), 404, "Not found"); when(get.execute()).thenThrow(notFoundException); assertThat(repository.getAppEngineApplication(mock(Credential.class), "projectId"), is(AppEngine.NO_APPENGINE_APPLICATION)); }
Example #7
Source File: ProjectRepositoryTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test(expected = ProjectRepositoryException.class) public void testHasAppengineApplication_GoogleJsonResponseException() throws IOException, ProjectRepositoryException { Apps.Get get = initializeGetRequest(); GoogleJsonResponseException exception = GoogleJsonResponseExceptionFactoryTesting .newMock(new JacksonFactory(), 500, "Server Error"); when(get.execute()).thenThrow(exception); repository.getAppEngineApplication(mock(Credential.class), "projectId"); }
Example #8
Source File: CredentialHelperTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private static Credential createCredential(String accessToken, String refreshToken) { GoogleCredential credential = new GoogleCredential.Builder() .setTransport(new NetHttpTransport()) .setJsonFactory(new JacksonFactory()) .setClientSecrets(Constants.getOAuthClientId(), Constants.getOAuthClientSecret()) .build(); credential.setAccessToken(accessToken); credential.setRefreshToken(refreshToken); return credential; }
Example #9
Source File: GCMIntentService.java From solutions-mobile-shopping-assistant-backend-java with Apache License 2.0 | 5 votes |
public GCMIntentService() { super(PROJECT_NUMBER); Deviceinfoendpoint.Builder endpointBuilder = new Deviceinfoendpoint.Builder( AndroidHttp.newCompatibleTransport(), new JacksonFactory(), new HttpRequestInitializer() { public void initialize(HttpRequest httpRequest) { } }); endpoint = CloudEndpointUtils.updateBuilder(endpointBuilder).build(); }
Example #10
Source File: GoogleAuth.java From oncokb with GNU Affero General Public License v3.0 | 5 votes |
private static void createDriveService() throws GeneralSecurityException, IOException, URISyntaxException { HttpTransport httpTransport = new NetHttpTransport(); JacksonFactory jsonFactory = new JacksonFactory(); DRIVE_SERVICE = new Drive.Builder(httpTransport, jsonFactory, null) .setApplicationName("Oncoreport") .setHttpRequestInitializer(CREDENTIAL).build(); }
Example #11
Source File: GoogleAuth.java From oncokb with GNU Affero General Public License v3.0 | 5 votes |
private static void createSpreadSheetService() throws GeneralSecurityException, IOException, ServiceException { HttpTransport httpTransport = new NetHttpTransport(); JacksonFactory jsonFactory = new JacksonFactory(); SPREADSHEET_SERVICE = new SpreadsheetService("data"); SPREADSHEET_SERVICE.setOAuth2Credentials(CREDENTIAL); }
Example #12
Source File: PostListRequest.java From Broadsheet.ie-Android with MIT License | 5 votes |
@Override public PostList loadDataFromNetwork() throws Exception { Log.d("PostListRequest", "Call web service " + generateUrl()); HttpRequest request = getHttpRequestFactory().buildGetRequest(new GenericUrl(generateUrl())); request.setParser(new JacksonFactory().createJsonObjectParser()); return request.execute().parseAs(getResultType()); }
Example #13
Source File: PostRequest.java From Broadsheet.ie-Android with MIT License | 5 votes |
@Override public SinglePost loadDataFromNetwork() throws Exception { Log.d(TAG, url); HttpRequest request = getHttpRequestFactory().buildGetRequest(new GenericUrl(url)); request.setParser(new JacksonFactory().createJsonObjectParser()); return request.execute().parseAs(getResultType()); }
Example #14
Source File: GCMIntentService.java From solutions-mobile-shopping-assistant-android-client with Apache License 2.0 | 5 votes |
/** * Called when a registration token has been received. The method calls insertDeviceInfo API on * the backend passing the device registration id, so the backend can use it for sending push * notifications. * * @param context application's context * @param registration the registration id returned by the GCM service */ @Override public void onRegistered(Context context, String registration) { try { Builder endpointBuilder = new Shoppingassistant.Builder( AndroidHttp.newCompatibleTransport(), new JacksonFactory(), CloudEndpointBuilderHelper.getRequestInitializer()); DeviceInfoEndpoint deviceInfoEndpoint = CloudEndpointBuilderHelper.updateBuilder(endpointBuilder).build().deviceInfoEndpoint(); deviceInfoEndpoint.insert(new DeviceInfo().setDeviceRegistrationID(registration)).execute(); } catch (IOException e) { e.printStackTrace(); } }
Example #15
Source File: RegisterActivity.java From solutions-mobile-shopping-assistant-backend-java with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); Button regButton = (Button) findViewById(R.id.regButton); registerListener = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: if (GCMIntentService.PROJECT_NUMBER == null || GCMIntentService.PROJECT_NUMBER.length() == 0) { showDialog("Unable to register for Google Cloud Messaging. " + "Your application's PROJECT_NUMBER field is unset! You can change " + "it in GCMIntentService.java"); } else { updateState(State.REGISTERING); try { GCMIntentService.register(getApplicationContext()); } catch (Exception e) { Log.e(RegisterActivity.class.getName(), "Exception received when attempting to register for Google Cloud " + "Messaging. Perhaps you need to set your virtual device's " + " target to Google APIs? " + "See https://developers.google.com/eclipse/docs/cloud_endpoints_android" + " for more information.", e); showDialog("There was a problem when attempting to register for " + "Google Cloud Messaging. If you're running in the emulator, " + "is the target of your virtual device set to 'Google APIs?' " + "See the Android log for more details."); updateState(State.UNREGISTERED); } } return true; case MotionEvent.ACTION_UP: return true; default: return false; } } }; unregisterListener = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: updateState(State.UNREGISTERING); GCMIntentService.unregister(getApplicationContext()); return true; case MotionEvent.ACTION_UP: return true; default: return false; } } }; regButton.setOnTouchListener(registerListener); /* * build the messaging endpoint so we can access old messages via an endpoint call */ MessageEndpoint.Builder endpointBuilder = new MessageEndpoint.Builder( AndroidHttp.newCompatibleTransport(), new JacksonFactory(), new HttpRequestInitializer() { public void initialize(HttpRequest httpRequest) { } }); messageEndpoint = CloudEndpointUtils.updateBuilder(endpointBuilder).build(); }
Example #16
Source File: OAuth2WebViewActivity.java From apigee-android-sdk with Apache License 2.0 | 4 votes |
@Override protected Void doInBackground(String...params) { if (this.url.startsWith(this.redirectURL)) { OAuth2WebViewActivity.this.handledRedirect = true; this.resultIntent = new Intent(); try { Map<String,String> urlQueryParams = this.extractQueryParams(url); if( urlQueryParams.get(OAuth2AccessTokenExtraKey) != null ) { this.resultIntent.putExtra(OAuth2AccessTokenExtraKey,urlQueryParams.get(OAuth2AccessTokenExtraKey)); if( urlQueryParams.get(OAuth2ExpiresInExtraKey) != null ) { this.resultIntent.putExtra(OAuth2ExpiresInExtraKey,urlQueryParams.get(OAuth2ExpiresInExtraKey)); } if( urlQueryParams.get(OAuth2RefreshTokenExtraKey) != null ) { this.resultIntent.putExtra(OAuth2RefreshTokenExtraKey, urlQueryParams.get(OAuth2RefreshTokenExtraKey)); } } else if ( urlQueryParams.get(OAuth2AccessCodeExtraKey) != null ) { String authorizationCode = urlQueryParams.get(OAuth2AccessCodeExtraKey); resultIntent.putExtra(OAuth2AccessCodeExtraKey, authorizationCode); OAuth2WebViewActivity.this.setResult(RESULT_OK,resultIntent); AuthorizationCodeTokenRequest codeTokenRequest = new AuthorizationCodeTokenRequest(new NetHttpTransport(),new JacksonFactory(),new GenericUrl(this.accessTokenURL),authorizationCode); codeTokenRequest.setRedirectUri(this.redirectURL); if( clientId != null ) { codeTokenRequest.set("client_id", clientId); } if( clientSecret != null ) { codeTokenRequest.set("client_secret", clientSecret); } HttpResponse response = codeTokenRequest.executeUnparsed(); InputStream in = response.getContent(); InputStreamReader is = new InputStreamReader(in); StringBuilder sb=new StringBuilder(); BufferedReader br = new BufferedReader(is); String read = br.readLine(); while(read != null) { sb.append(read); read =br.readLine(); } String accessTokenStringData = sb.toString(); Map<String,String> queryParams = this.extractQueryParams(accessTokenStringData); if( queryParams.get(OAuth2AccessTokenExtraKey) != null ) { this.resultIntent.putExtra(OAuth2AccessTokenExtraKey,queryParams.get(OAuth2AccessTokenExtraKey)); } if( queryParams.get(OAuth2ExpiresInExtraKey) != null ) { this.resultIntent.putExtra(OAuth2ExpiresInExtraKey, queryParams.get(OAuth2ExpiresInExtraKey)); } if( queryParams.get(OAuth2RefreshTokenExtraKey) != null ) { this.resultIntent.putExtra(OAuth2RefreshTokenExtraKey, queryParams.get(OAuth2RefreshTokenExtraKey)); } } else if (urlQueryParams.get(OAuth2ErrorExtraKey) != null) { this.resultIntent.putExtra(OAuth2ErrorExtraKey,urlQueryParams.get(OAuth2ErrorExtraKey)); OAuth2WebViewActivity.this.setResult(RESULT_OK, resultIntent); } } catch (Exception e) { this.resultIntent.putExtra("error",e.getLocalizedMessage()); e.printStackTrace(); } } return null; }
Example #17
Source File: GmailServiceModule.java From mail-importer with Apache License 2.0 | 4 votes |
@Provides @Singleton JsonFactory provideJsonFactory() { return new JacksonFactory(); }
Example #18
Source File: TictactoeTest.java From endpoints-java with Apache License 2.0 | 4 votes |
@Before public void setUp() { api = TestUtils.configureApiClient( new Tictactoe.Builder(new NetHttpTransport(), new JacksonFactory(), null)).build(); }
Example #19
Source File: WaxTest.java From endpoints-java with Apache License 2.0 | 4 votes |
@Before public void setUp() { wax = TestUtils.configureApiClient( new Wax.Builder(new NetHttpTransport(), new JacksonFactory(), null)).build(); }
Example #20
Source File: JelectrumDBCloudData.java From jelectrum with MIT License | 3 votes |
private void openStorage() throws java.security.GeneralSecurityException, java.io.IOException { NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); GoogleCredential cred = openCredential(); bigstore = new Storage.Builder(httpTransport, new JacksonFactory(), cred).setApplicationName("jelectrum/1.0").build(); }