Google oAuth Authentication fails after deployment in IIS Server

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.5. with the below code

UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret } , scopes , “adam03032017” , CancellationToken.None , new FileDataStore(GoogleWebAuthorizationBroker.Folder)).Result;

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.