2
Answers

Google oAuth Authentication fails after deployment in IIS Se

Ask a question
Ravi Yadav

Ravi Yadav

7y
488
1

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)