1

I have a suite of selenium data driven testcases and I am trying to migrate my test data from Excel to Google Sheets, so apparently I need to use OAuth2. I have very little understanding in this area and am fairly new to programming with java.

I found this helpful link on stackoverflow: Create Spreadsheet using Google Spreadsheet API in Google drive in Java

Very helpful, HOWEVER, for some reason, Eclipse doesn't like the following line:

service.setOAuth2Credentials(credential);

Eclipse reports the following:

setOAuth2Credentials(credential) is not defined for the type SpreadsheetService.

There is a setOAuthCredential for type SpreadsheetService, but it takes 2 arguments instead of the one shown in the above example (taken from link).

My question is how can I get the example code to work (or at least compile)? Any suggestions or help would be greatly appreciated.

Community
  • 1
  • 1
AndyB
  • 31
  • 8

2 Answers2

1

I figured out that the cause was due to some local environmental issue in Eclipse. Not sure exactly what that issue was, but once I recreated a brand new project with the required jar files and the example code, everything started to work beautifully. Now I am able to read and write data from Google sheets. Awesome!

Updated: Found out the cause was an unnecessary jar file in my java build path. The offending jar file? com.google.gdata.jar - not sure how that ended up in my project, but when I recreated a new project, I didn't include that file. So after removing this file from my old project it too ran great.

AndyB
  • 31
  • 8
-1

I found core-1.47.1.jar has setOAuth2Credentials(..) method defined in SpreadsheetService.

dur
  • 15,689
  • 25
  • 79
  • 125