0

I'm trying to use the goolge-oauth2 library, and when i call the refresh token method on the class I have this error:

Caused by:

java.lang.NoClassDefFoundError: javax/net/ssl/HttpsURLConnection
        at com.google.api.client.http.javanet.NetHttpTransport.buildRequest(NetHttpTransport.java:152)
        at com.google.api.client.http.javanet.NetHttpTransport.buildRequest(NetHttpTransport.java:55)
        at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:889)
        at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:441)
        at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:157)
        at com.google.auth.oauth2.OAuth2Credentials.refreshIfExpired(OAuth2Credentials.java:174)

This is the code I use to retrieve the ServiceAccountCredentials object

ServiceAccountCredentials googleCredential = ServiceAccountCredentials.fromPkcs8(client_id, client_email, private_key,private_key_id, Arrays.asList(scope));
googleCredential.refreshIfExpired();

using "https://www.googleapis.com/auth/iam" as scope

now this is the first time i need to connect to an Https url so maybe i'm missing something...

Angelo Mendes
  • 905
  • 13
  • 24
  • What kind of software are you developing? The missing class is part of the JRE, but if you are developing e. g. a OSGi plugin, access to it might be restricted. So the context you're working in might be relevant here. –  Jul 29 '20 at 05:21
  • i'm working on an OSGI plugin, on jboss fuse platform, so this can explain also the fact that when I tested with a main class it worked from my local eclipse... – Pier Luigi Jul 29 '20 at 08:11

1 Answers1

0

https://www.eclipse.org/forums/index.php/t/1072090/ says you need to import javax.net.ssl in your manifest. I'm not an OSGi developer so I'm not sure how exactly that works but it shouldn't be too hard to find documentation on that.