Reputation: 149
I created a new project in my Google Account on https://console.developers.google.com/apis and also created Credentials for it. Then I just use the Client ID & Client Secret in that Credentials in my C# project to connect to my Google Drive with the following simple code:
UserCredential credential;
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets { ClientId = "YourClientId", ClientSecret = "YourClientSecret" },
new[] { DriveService.Scope.Drive,
DriveService.Scope.DriveFile },
"user",
CancellationToken.None,
new FileDataStore("Drive.Auth.Store")).Result; }
BaseClientService service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Testing Application",
});
And then just use some simple codes to upload a file to the Google Drive and it's successful. However, I would like to ask how can I change the name when using the browser to look at the file in Google Drive, there is a field in the file Details like:
Created Dec 13, 2016 with My Application
so how can I change the "My Application" to my wanted name in the C# code? Currently this name is same as the Product name shown to users in OAuth consent screen in my created project in Google Drive API on https://console.developers.google.com/apis, or I have to create multiple projects in order to have different names? but seems it sounds so silly. Firstly I think the name should be the ApplicationName when initializing the DriveService but it's not. (So what is the usage of the ApplicationName?)
Thanks a lot for helping!
Upvotes: 2
Views: 226
Reputation: 117301
You cant change the project name programmatically there is actually no way to change anything in the google developer console programmatically.
It is best IMO to have each application assigned to its own project on Google developer console. The main reason for this is if there is a problem with one of your projects google will block it and your other projects will continue to work. Unless you are really bad then your whole account gets blocked.
Answer: Yes you will have to create new projects.
Note: I am still trying to figure out where the "with [application]" is coming from. Its not part of the metadata for the file itself. So where exactly is Google drive getting this information. I know the Client library sets some "weird" stuff using the ApplicationName but its not that since its getting it from the project itself that created the file. Which leads me to believe its getting set at upload by the authentication.
Upvotes: 1