Forums - C# Corner

Forum guidelines
Ravi Yadav

Ravi Yadav

  • 1.3k
  • 165
  • 23.2k

Google oAuth Authentication fails after deployment in IIS Se

Mar 3 2017 7:24 AM

c# - Gmail API not working if the asp.net application is hosted in IIS however it is working

in localhost when executed from visual studio

I am using .Net 4.0 with the below code

 
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. 


Answers (2)