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 [email protected].
To post to this group, send email to [email protected].
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.