I am new to Google API and try to use its client library for .NET on Windows Phone.
I'm using GoogleWebAuthorizationBroker to authorize user. The thing is that it has an "userID" parameter. What is it? Is it Google Email account? How do I know user's account the first time the app runs?
Thanks,
This is going to be a long answer I am copying the text mostly from my tutorial Google .net – FileDatastore demystified
Lets look at FileDataStore. When the following code authenticates. A folder called Drive.Auth.Store will be created in the %AppData% directory on the machine executing the code.
So we will have a new directory called %AppDatat%\Drive.Auth.Store . When I check my machine I find it here C:\Users\lindaHP\AppData\Roaming\Drive.Auth.Store
UserCredential credential;
using (var stream = new FileStream(clientSecretsJsonFilePath
,FileMode.Open
,FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { DriveService.Scope.Drive, DriveService.Scope.DriveFile },
"LookIAmAUniqueUser",
CancellationToken.None,
new FileDataStore("Drive.Auth.Store")
).Result;
}
Assuming the user clicks accept on the authentication request screen, a new file will be created in that directory with the following structure:
Google.Apis.Auth.OAuth2.Responses.TokenResponse-LookIAmAUniqueUser.TokenResponse-LookIAmAUniqueUser
Answer:
Userid
is what ever you want it to be its just a string. It is just used to differentiate between multiple users on the same machine saving authentication.
When you want to load a user again you pass the userid for that user and the client library will load his or her authentication. This is not really needed on windows phone. There should probably just be one user.
If you want to load a different user you change the userid and it will save the authentication for that user (or load it if the user in question has already authenticated your application)