i am using c# language the service get me exception
"failed to launch browser with https //accounts.google.com/o/oauth2/v2/auth"
the steps that i followed :
- Enable Google drive api service from google console developer
- Generate client id, client secret (i tried two type of OAuth Client id type {Web Application and Other} the two type get me the same exception
My code is :
public File InsertFile(byte[] byteArray)
{
// File's metadata
File body = new File();
body.Title = "my title";
body.Description = "my description";
body.MimeType = "image/jpg";
// File's content.
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
try
{
var credential = Authentication();
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = string.Format("{0} elfeedback-project", System.Diagnostics.Process.GetCurrentProcess().ProcessName),
});
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "image/jpg");
request.UploadAsync();
File file = request.ResponseBody;
return file;
}
catch (Exception ex)
{
return null;
}
}`
the Authentication get exception :
`public UserCredential Authentication()
{
string[] scopes = { DriveService.Scope.Drive,
DriveService.Scope.DriveFile,
};
UserCredential credential;
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "my client id",
ClientSecret = "my client secret"
},
scopes,
"myGmail Account that authenticated (client id ,client secret)",
CancellationToken.None,
new FileDataStore("Drive.Auth.Store")).Result;
return credential;
}