Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts,

I am using google drive API to upload file to drive.I am using OAuth2 with "application type : Other". Everything works fine on localhost while running code and files are uploaded as expected. In local development environment, browser returns a Google consent screen for allowing different permissions to api and once clicked on "Allow" button, the file gets uploaded as expected to drive. But when this working code is published on IIS server , it gives "502:Bad Gateway.Web server received an invalid response while acting as a gateway or proxy server.".
After debugging I found that below line of code is returning error.


credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                 Scopes,
                "my email id",
                CancellationToken.None,
                new FileDataStore(credPath, true)).Result;


I think the Google consent window to allow permission is failing to open on IIS Server. How to solve this issue? Please suggest.

Also When I try to access API using "application type : web application", it gives me an error Error: redirect_uri_mismatch on localhost itself.

I am Searching for solution from last week. I am unable to understand what redirect uri should I provide? Any suggestions or ideas to solve this error?

What I have tried:

I tried many options with redirect uri like http://localhost:62283 , http://localhost:62283/Home/Index.cshtml , http://localhost:62283/Home etc , tried changing the 62283 to some other port also. 
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900