I am using the Google.net client library to authenticate to a Google API this code works locally but when I uploaded it to my server I get this error
"Failed to launch browser with \"https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=123&redirect_uri=http%3A%2F%2Flocalhost%3A54597%2Fauthorize%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive\" for authorization. See inner exception for details."
my code
Google.Apis.Drive.v3.DriveService service = null;
try
{
UserCredential credential;
// string strUploadFolder = ConfigurationManager.AppSettings["UploadFolder"];
string credPath = AppDomain.CurrentDomain.BaseDirectory;
credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = ConfigurationManager.AppSettings["client_id"],
ClientSecret = ConfigurationManager.AppSettings["client_secret"],
},
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
// Create Drive API service.
service = new Google.Apis.Drive.v3.DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
}
catch (Exception ex)
{
throw;
}
return service;