P
P
pfedorov0310902021-07-20 16:36:36
Google
pfedorov031090, 2021-07-20 16:36:36

How to work with the Google Sheets Java API?

I'm trying to connect the Google Sheets API to a project. I follow the instructions:
https://developers.google.com/sheets/api/quickstar...
I get an error on the first step:
IdeaProjects\Sheets_v3>gradle init --type basic

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\fedorov.p\IdeaProjects\Sheets_v3\build.gradle' line: 14

* What went wrong:
A problem occurred evaluating root project 'Sheets_v3'.
> Could not find method compile() for arguments [com.google.api-client:google-api-client:1.30.4] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 849ms

Why doesn't it exit? Grandle updated, IDE too
Code:

apply plugin: 'java'
apply plugin: 'application'

mainClassName = 'SheetsQuickstart'
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.api-client:google-api-client:1.30.4'
    compile 'com.google.oauth-client:google-oauth-client-jetty:1.30.6'
    compile 'com.google.apis:google-api-services-sheets:v4-rev581-1.25.0'
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pfedorov031090, 2021-07-20
@pfedorov031090

Now the program flows here:
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
.setAccessType("offline")
.build();
Before that I did a service account. Help me please!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question