"Failed to launch browser with \"https://accounts.google.com/o/oauth2/v2

Siwar Ha

Member
Joined
May 28, 2021
Messages
5
Programming Experience
Beginner
C#:
        public static DriveService Execution(string ApplicationName, string credentials)
        {
            UserCredential credential;

            using (var stream =
                new FileStream(credentials, FileMode.Open, FileAccess.Read))
            {

                string credPath = "token.json";

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                            GoogleClientSecrets.Load(stream).Secrets,
                            Scopes,
                            "XXXX",
                            CancellationToken.None,
                            new FileDataStore(credPath, true)).Result;
            }
            // Create Drive API service.
            var service = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = ApplicationName,
            });

            return service;
        }


I know that i have to replace GoogleWebAuthorizationBroker with GoogleAuthorizationCodeFlow but i didnt get what should REFRESH_TOKEN get like value ?
any help please ?
 

Siwar Ha

Member
Joined
May 28, 2021
Messages
5
Programming Experience
Beginner
C#:
        public static DriveService Execution(string ApplicationName, string credentials)
        {
            var clientSecrets = new ClientSecrets
            {
                ClientId = "xxxx",
                ClientSecret = "xxxx"
            };

            var credential = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
            {
                ClientSecrets = clientSecrets,
                Scopes =Scopes
            });
            // Create Drive API service.
            var service = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer =// I HAVE A PROBLEM HERE
                ApplicationName = ApplicationName,
            });

            return service;
        }


WHAT I have to put in HttpClientInitializer ? because i used to use GoogleWebAuthorizationBroker and it accept credential like a value
 

Sheepings

Well-known member
Joined
Sep 5, 2018
Messages
2,038
Programming Experience
10+
And?

You are only passing two of the three required parameters.

because i used to use GoogleWebAuthorizationBroker and it accept credential like a value

What value? Values can be of different types...

This should be moved to third party. It's a Google API question non specific to C#.
 
Top Bottom