InputStream in = GmailQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
InputStream ins = new FileInputStream(CREDENTIALS_FILE_PATH);
I have added also following line: import com.google.api.client.http.HttpRequest;
JAR files are imported, project is running and browser window is opened to get token. After successful authorization I got error message:
This means that com.google.http-client.google-http-client_1.22.0.jar file is bundled in Katalon Studio. The bundled jar will have precedence over the jar files in the <projectdir>/Drivers folder. To be precise, the precedence is determined by the order of <classpathentriy> lines in the .classpath file. Earlier wins.
I suppose that this Exception occured becase the com.google.api.client.http.HttpRequest class was loaded from the older version 1.22.0.
How to workaround?
The .classpath file is given by Katalon to you. You can not change it at all. You are suppose to live with the versions of external libs bundled in the Katalon Studion ver x.x.x if you are to develop a Custom Keyword for Katalon Studio.
In orther words, you can not take initiative which version of google-api-client-x.x.x.jar to choose. Rather, you have to find out which version of google-api-client-x.x.x.jar can coexist with the com.google.http-client.google-http-client_1.22.0.jar which is bundled in KS, and use that version to build your Custom Keyword.
Older version Gmail API jar might not work well with the recent version of Gmail services. I am not sure, but the google-api-client-1.23.0 has already been updated to 1.31.3 until now. I suppose there have been many changes in the Gmail service. Therefore I guess @plaidshirtakos may find that he really need the recent version of google-api-client-x.x.x.jar such as 1.31.3. In this case he will get stuck, as he can not take the initiative to choose the versions of Google API.
The Gmail API used by the “Read and Write Gmail Messages plugin” might be too old to work with the recent version of Gmail service. This might be the reason why many people report problems about the plugin. For example,
Is there any way for @plaidshirtakos to change the build path of KS so that his custom Groovy code refer to the google-http-client-1.39.1.jar in the Drivers folder rather than the com.google.http-client.google-http-client_1.22.0.jar bundled in the KS 7.9.1?
The last resort for you would be removing the /Katalon_Studio_Windows_64-7.9.0/plugins/com.google.http-client.google-http-client_1.22.0.jar file. You want to remove it manually by rm file in command line or DEL in Windows Explorer. Just try to see what sort of difficulties you get next.
To prevent adding com.google.http-client.google-http-client_1.22.0.jar to project classpath, you should go to Project Settings/Library Management and add this jar name to Exclude field then reopen your project.
i remove this lib from library management and i found this error now :
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
Caused by: java.lang.ClassNotFoundException: JsonFactory
... 14 more