Use installable Google APIs lib for Java

This commit is contained in:
Stephen McDonald
2024-02-22 09:11:48 +11:00
parent f4f62d12e2
commit cd24293464
8 changed files with 16 additions and 32 deletions

View File

@@ -10,14 +10,12 @@ repositories {
}
dependencies {
// Replace with path to your local download of the Google Wallet library
implementation files('lib/libwalletobjects_public_java_lib_v1.jar')
implementation 'com.auth0:java-jwt:3.19.1'
implementation 'com.auth0:jwks-rsa:0.9.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.4.2'
implementation 'com.google.apis:google-api-services-oauth2:v2-rev20200213-2.0.0'
implementation 'com.google.api-client:google-api-client:1.25.0'
implementation 'com.google.api-client:google-api-client:2.2.0'
implementation 'com.google.apis:google-api-services-walletobjects:v1-rev20240220-2.0.0'
implementation 'com.google.auth:google-auth-library-oauth2-http:1.10.0'
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
implementation 'javax.json:javax.json-api:1.1'

View File

@@ -26,7 +26,7 @@ import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.*;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.walletobjects.Walletobjects;
import com.google.api.services.walletobjects.*;
import com.google.api.services.walletobjects.model.*;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
@@ -64,11 +64,9 @@ public class DemoEventTicket {
*
*/
public void auth() throws Exception {
String scope = "https://www.googleapis.com/auth/wallet_object.issuer";
credentials =
GoogleCredentials.fromStream(new FileInputStream(keyFilePath))
.createScoped(List.of(scope));
.createScoped(List.of(WalletobjectsScopes.WALLET_OBJECT_ISSUER));
credentials.refresh();
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

View File

@@ -26,7 +26,7 @@ import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.*;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.walletobjects.Walletobjects;
import com.google.api.services.walletobjects.*;
import com.google.api.services.walletobjects.model.*;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
@@ -64,11 +64,9 @@ public class DemoFlight {
*
*/
public void auth() throws Exception {
String scope = "https://www.googleapis.com/auth/wallet_object.issuer";
credentials =
GoogleCredentials.fromStream(new FileInputStream(keyFilePath))
.createScoped(List.of(scope));
.createScoped(List.of(WalletobjectsScopes.WALLET_OBJECT_ISSUER));
credentials.refresh();
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

View File

@@ -26,7 +26,7 @@ import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.*;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.walletobjects.Walletobjects;
import com.google.api.services.walletobjects.*;
import com.google.api.services.walletobjects.model.*;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
@@ -64,11 +64,9 @@ public class DemoGeneric {
*
*/
public void auth() throws Exception {
String scope = "https://www.googleapis.com/auth/wallet_object.issuer";
credentials =
GoogleCredentials.fromStream(new FileInputStream(keyFilePath))
.createScoped(List.of(scope));
.createScoped(List.of(WalletobjectsScopes.WALLET_OBJECT_ISSUER));
credentials.refresh();
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

View File

@@ -26,7 +26,7 @@ import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.*;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.walletobjects.Walletobjects;
import com.google.api.services.walletobjects.*;
import com.google.api.services.walletobjects.model.*;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
@@ -64,11 +64,9 @@ public class DemoGiftCard {
*
*/
public void auth() throws Exception {
String scope = "https://www.googleapis.com/auth/wallet_object.issuer";
credentials =
GoogleCredentials.fromStream(new FileInputStream(keyFilePath))
.createScoped(List.of(scope));
.createScoped(List.of(WalletobjectsScopes.WALLET_OBJECT_ISSUER));
credentials.refresh();
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

View File

@@ -26,7 +26,7 @@ import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.*;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.walletobjects.Walletobjects;
import com.google.api.services.walletobjects.*;
import com.google.api.services.walletobjects.model.*;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
@@ -64,11 +64,9 @@ public class DemoLoyalty {
*
*/
public void auth() throws Exception {
String scope = "https://www.googleapis.com/auth/wallet_object.issuer";
credentials =
GoogleCredentials.fromStream(new FileInputStream(keyFilePath))
.createScoped(List.of(scope));
.createScoped(List.of(WalletobjectsScopes.WALLET_OBJECT_ISSUER));
credentials.refresh();
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

View File

@@ -26,7 +26,7 @@ import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.*;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.walletobjects.Walletobjects;
import com.google.api.services.walletobjects.*;
import com.google.api.services.walletobjects.model.*;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
@@ -64,11 +64,9 @@ public class DemoOffer {
*
*/
public void auth() throws Exception {
String scope = "https://www.googleapis.com/auth/wallet_object.issuer";
credentials =
GoogleCredentials.fromStream(new FileInputStream(keyFilePath))
.createScoped(List.of(scope));
.createScoped(List.of(WalletobjectsScopes.WALLET_OBJECT_ISSUER));
credentials.refresh();
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();

View File

@@ -26,7 +26,7 @@ import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.*;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.walletobjects.Walletobjects;
import com.google.api.services.walletobjects.*;
import com.google.api.services.walletobjects.model.*;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
@@ -63,11 +63,9 @@ public class DemoTransit {
*
*/
public void auth() throws Exception {
String scope = "https://www.googleapis.com/auth/wallet_object.issuer";
credentials =
GoogleCredentials.fromStream(new FileInputStream(keyFilePath))
.createScoped(List.of(scope));
.createScoped(List.of(WalletobjectsScopes.WALLET_OBJECT_ISSUER));
credentials.refresh();
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();