0

I have a web application running on web server IIS, so to initialize service we need GoogleAuthorizationCodeFlow instead of GoogleWebAuthorizationBroker.

What should be passed in HttpClientInitializer when creating a service object?

    var flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
                        {
                            ClientSecrets = new ClientSecrets
                            {
                                ClientId = _clientId,
                                ClientSecret = _clientSecret
                            },
                            Scopes = UserAccountCreds.SCOPES,
                            DataStore = new FileDataStore(@"C:\GoogleDriveViewer\DataStore", true)
                        });  

UserCredential credentials = new UserCredential(flow, "user", token); // HOW DO YOU GET REFRESH TOKEN
                    DriveService service = new DriveService(new BaseClientService.Initializer()
                    {
                        HttpClientInitializer = , // HELP NEEDED HERE
                        ApplicationName = "Drive API Sample",
                    });
Atihska
  • 4,803
  • 10
  • 56
  • 98
  • try flow but why are you using GoogleAuthorizationFlow and not GoogleWebAuthorizationBroker? – Linda Lawton - DaImTo Mar 03 '16 at 07:33
  • @DalmTo: When I use GoogleWebAuthorizationBroker in installed apps, it works. But when I host on IIS, it hangs forever and doesn't proceed. So on reading several SO posts, I cam e across GoogleAuthorizationFlow that I am using above. But this requires refresh token, that I don't know where to get from. Also, just wanted to thank you as I am able to get this much understanding following ur tutorials. They have been of great help – Atihska Mar 03 '16 at 07:50
  • If you get GoogleAuthorizationCodeFlow working please post it I have never seen it used. I always use GoogleWebAuthorizationBroker – Linda Lawton - DaImTo Mar 03 '16 at 07:52
  • @DalmTo: I couldn't get GoogleAuthorizationCodeFlow working. Could you tell me how I can use GoogleWebAuthorizationBroker when my app is on IIS as website? I checked this SO post which had similar problem as mine: http://stackoverflow.com/questions/22598348/googlewebauthorizationbroker-in-mvc-for-google-drive-access – Atihska Mar 03 '16 at 07:55
  • Any hints here? I am still stuck here.. – Atihska Mar 03 '16 at 18:50
  • Did you managed to get it worked? – Manoj Sethi Aug 05 '18 at 01:55
  • @ManojSethi Sorry, I don't remember at all. Been a while now but check this if this helps: https://stackoverflow.com/questions/38390197/how-to-create-a-instance-of-usercredential-if-i-already-have-the-value-of-access. – Atihska Aug 05 '18 at 02:30

0 Answers0