I've done a little program in VB.NET that, basically, synchronizes a directory with Google Drive and then it obtains the sharing link and creates a shortcut file for that that uploaded file. All works fine and well. Now, my problem came when I started playing with different accounts instead of just the account I was running tests on. I observed that when I authenticate with this code:
Dim clientS As ClientSecrets = New ClientSecrets()
clientS.ClientId = "ClientID"
clientS.ClientSecret = "MySecret"
Dim scopes As IList(Of String) = New List(Of String)()
scopes.Add(DriveService.Scope.Drive)
scopes.Add(DriveService.Scope.DriveFile)
Dim credentials As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(clientS, scopes, Me.UserEmail, System.Threading.CancellationToken.None, New FileDataStore(Me.TokensFolderPath)).Result
Dim initializer As BaseClientService.Initializer = New BaseClientService.Initializer()
initializer.HttpClientInitializer = credentials
initializer.ApplicationName = "Drive API Test"
Me.service = New DriveService(initializer)
The first time this will open a browser window and ask the users for permissions to view, edit, ... your files. And then it creates a token to avoid asking next time the application runs. The issue is that even if I'm specifying a userEmail on the code, it doesn't care. It will just open the browser and ask permissions with whatever account you have active at that precise moment, and so, the token created will belong to that account and not to the one I specified.
Am I doing something wrong or there is something missing? Or maybe the API is just supposed to work like that and it always uploads the files to the account you are curremtly logged in.