Search code examples
google-api-dotnet-clientgoogle-oauthgoogle-oauth-.net-client

new FileDataStore in GoogleWebAuthorizationBroker results in a new port each time


So I followed a few examples from http://www.daimto.com/, namely http://www.daimto.com/webmaster-tools-api-with-c/. After a long night I was able to get it to work. the way I did that is by simply removing

new FileDataStore("Daimto.GoogleWebMasters.Auth.Store")

changing the code to:

  UserCredential credential = GoogleWebAuthorizationBroker(new ClientSecrets 
{ ClientId = clientId, ClientSecret = clientSecret }                                                                                            
, scopes                                                                                     
, userName                                                                                 
, CancellationToken.None                                                                      
, null).Result; // <-- notice null here

So is the datastore really necessary? when I add it, my IIS is generating a new port number each refresh, making it impossible to authorize url redirects in google. btw, I tried the physical full path of the directory, but it results the same.


Solution

  • It seems this solution was just the wrong way, perhaps just obsolete. Finally, I rewrote everything base on this. Now it works find both on local and published, and with FileDataStore.