Hi George, this is my code:

string[] scopes = new string[] { DriveService.Scope.Drive }; // Full access

 

            var keyFilePath = Environment.CurrentDirectory + 
"JSON_FILE_LOCATION";    

            if (!System.IO.File.Exists(keyFilePath))

            {

                Console.WriteLine("An Error occurred - Key file does not 
exist");

            }

 

            try

            {

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

                {

 

                    var googleCredential = GoogleCredential
.FromStream(stream);

                    if (googleCredential.IsCreateScopedRequired)

                    {

                        googleCredential.CreateScoped(scopes);

                    }

 

                    // Create the service.

                    DriveService service = new DriveService(new 
BaseClientService.Initializer()

                    {

                        HttpClientInitializer = googleCredential,

                        ApplicationName = "APP_NAME",

                    });

 

                    try

                    {

                        FilesResource.ListRequest listRequest = 
service.Files.List();    

                        FileList files = listRequest.Execute();

                    }

                    catch (Exception e)

                    {

                        Console.WriteLine("An error occurred: " + 
e.Message);

                    }

 

                   

                }

            }

            catch (Exception ex)

            {

                Console.WriteLine(ex.InnerException);

            }

 

        }



And this is the exception:


Eccezione generata: 'Google.GoogleApiException' in mscorlib.dll

An error occurred: Google.Apis.Requests.RequestError

Invalid Credentials [401]

Errors [

       Message[Invalid Credentials] Location[Authorization - header] 
Reason[authError] Domain[global]

]

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/5d29ee26-b41e-4827-9539-9a50bb6e690c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • [google-appengine]... Daniele Volpe
    • [google-appen... 'George (Cloud Platform Support)' via Google App Engine
      • [google-a... Daniele Volpe
    • [google-appen... Daniele Volpe
      • [google-a... 'George (Cloud Platform Support)' via Google App Engine
        • [goog... Daniele Volpe
          • [... Daniele Volpe
            • ... 'George (Cloud Platform Support)' via Google App Engine
          • [... 'George (Cloud Platform Support)' via Google App Engine
          • [... 'George (Cloud Platform Support)' via Google App Engine

Reply via email to