I followed the Java Quickstart guide (
Java Quickstart | Apps Script | Google Developers) and managed to get the demo program working. In that program the Java app creates a script and receives a return of the link to the script edit page.
I'm trying to make a program that call an already existing script that creates a google form but I keep getting errors of "ACCESS_TOKEN_SCOPE_INSUFFICIENT" and "Request had insufficient authentication scopes".
Below is my current code:
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
Script service = new Script.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
.setApplicationName(APPLICATION_NAME)
.build();
Script.Projects projects = service.projects();
String scriptId = "[what I believe to be my script id]";
ExecutionRequest request = new ExecutionRequest();
Operation op = service.scripts().run(scriptId, request).execute();
My script works when running it from my browser.
and when going to this link it gets a 404 error
So can anyone help point me to what the issue is. Is it that I've given it the wrong id as shown by the 404 error? Bare in mind the link given in the script editor works fine with the same "id" but the link is different. It has a "/macros/" path in it. Is this wrong?
Or have I given incorrect scopes somewhere else? Because I've got it in 2 places is there more?? (Jesus this Google authentication is complicated)
Or perhaps something else?
I've found so little information on what seems to be the basics, at least to me, just calling a script from a Java app so any help would be greatly appreciated :)
I can get back quickly with any more info if needed