Java Action to generate a Google Credentials Token for a Google Service Account

Hi I try to setup a Java Action to get a Google Credentials Token, which i can use to authenticate with oAuth to Google API with a Google Service Account. I have creates a Google Service Account with a Key. This key i transfered as InputJSON, but i get no token back and no error message. I am not sure if this is an issue on mendix side or on google side. Has anyone experiance with this? Thanks Stephan        GoogleCredential credential = GoogleCredential.fromStream(new ByteArrayInputStream(InputJSON.getBytes()))         .createScoped(Lists.newArrayList(""));   // This file was generated by Mendix Studio Pro. // // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. // Special characters, e.g., é, ö, à, etc. are supported in comments. package workflowengine.actions; import com.mendix.systemwideinterfaces.core.IContext; import com.mendix.webui.CustomJavaAction; import; import; import; import java.util.*; import com.mendix.systemwideinterfaces.core.IMendixObject; import; import; import; import; import; import; public class GoogleCredentials extends CustomJavaAction<java.lang.String> {     private java.lang.String InputJSON;     public GoogleCredentials(IContext context, java.lang.String InputJSON)     {         super(context);         this.InputJSON = InputJSON;     }     @java.lang.Override     public java.lang.String executeAction() throws Exception     {         // BEGIN USER CODE                  ByteArrayInputStream str = new ByteArrayInputStream(InputJSON.getBytes());                  GoogleCredential credential = GoogleCredential.fromStream(new ByteArrayInputStream(InputJSON.getBytes()))         .createScoped(Lists.newArrayList(""));              return credential.getAccessToken();         // END USER CODE     }     /**      * Returns a string representation of this action      */     @java.lang.Override     public java.lang.String toString()     {         return "GoogleCredentials";     }     // BEGIN EXTRA CODE     // END EXTRA CODE
1 answers

Hi Stephan, 

The functionality you are building is already available in the JWT module in the App Store. You could just use this module, or check out the Java functions in that module to see how this action is performed there!