DSL wrappers for java google libs
repositories {
mavenCentral()
}
- Kotlin DSL:
implementation("ru.raysmith:google:2.0.0")- Kotlin with TOML:
raysmith-google = { module = "ru.raysmith:google", version = "2.0.0" }implementation(libs.raysmith.google)- Groovy:
implementation 'ru.raysmith:google:2.0.0'Initialize service:
- Create or select existed project at Google Cloud Console
- Enable API Service (e.g. Google Sheets API)
- Create Service Accounts Credentials
- Add JSON key for created service account and download file.
- Add downloaded
my_secret.jsonto resources/path/to/secrets/my_secret.json
val service = GoogleSheetsService(GoogleSheetsService.service("MyApplication", "path/to/secrets/my_secret.json"))
service.Spreadsheets.Values.get(
spreadsheetId = "spreadsheetId",
range = Range("Sheet1"),
fields = ValueRangeFields.values + ValueRangeFields.majorDimension
).forEach { row ->
row.forEach { cell ->
println(cell.asString)
}
}