When I use the Debug Console to execute C#/.NET code to create a new project (ProjectResource.Create(...)
), I receive a "403 Forbidden" error. However, I still receive a Project
response and the API correctly creates a file in my Drive. Because Google does not expose what is happening under their API, I have no idea why I see that message in the Debug Console. No errors propagate to the runtime, and I have a strange feeling this is an erroneous output error message left from production.
Why is this happening, and can I remove / prevent this error?
Code:
var cpr = new CreateProjectRequest
{
Title = name
};
scriptID = projectResource.Create(cpr).Execute().ScriptId;
Error:
The caller does not have permission
Error object:
Google.Apis.Requests.RequestError
The caller does not have permission [403]
Errors [
Message[The caller does not have permission] Location[ - ] Reason[forbidden] Domain[global]
]
An alternative possibility might be an issue with the way I set up my Google Console Cloud, but considering the functionality is still intact, I cannot help but think I did it correctly. Furthermore, my credential authorizations all succeed without error.
I authorize my services in the following way:
scriptService = new ScriptService(new BaseClientService.Initializer()
{
ApiKey = apiKeyUser,
HttpClientInitializer = credential,
ApplicationName = applicationName
});
projectResource = new ProjectsResource(scriptService);
My API key is set up to function with both the Apps Script API and Drive API.
My OAuth Client ID is of type: other
(it's the only way for desktop applications).
Any thoughts?
PS In my efforts I tried using the DriveService
to do the same thing. I still receive the same error in Debug, and alas it still works just like above.
File body = new File()
{
MimeType = "google-apps.script",
Name = name,
};
var test = driveService.Files.Create(body);
test.Fields = "id";
var f = test.Execute();