c# - Gmail API not working if the asp.net application is hosted in IIS however it is working
UserCredential credential;
string gFolder = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/MyGoogleStorage");
string gFolder2 = Server.MapPath(AppSetting.Uploadpath.QuotePath);
using (var stream = new FileStream(gFolder + @"\client_secrets.json", FileMode.Open,
FileAccess.Read))
{
try
{
if (stream != null)
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { gmailScope },
userEmail,
CancellationToken.None,
new FileDataStore(gFolder2, false)
).Result;
}
}
catch (Exception E)
{
ExceptionLogging.LogException(GoogleClientSecrets.Load(stream).Secrets.ClientSecret);
}
finally
{
stream.Dispose();
}
}
The above code is working in localhost when i am execute from visual studio. But the same code is not working if i host the application in IIS.