Hello, Thanks for your answers. I guess I have correct settings since we are using the same service account with Google Adwords API. I enabled Sheets API with readonly rights (we just want to read the file) and added the sheets scope in the admin developper console to be able to use it on the domain.
Le jeudi 23 juin 2016 15:25:48 UTC+2, Olaf Stolle a écrit : > > Hello, > > which interests me too much, it would be kind of you if you die solution > would post. > > Are you sure you have the correct settings you all > > https://console.developers.google.com/apis/credentials?project=region1-0&authuser=0 > > > LG > > Olaf > > 2016-06-23 14:53 GMT+02:00 Karthick Kumar <[email protected] > <javascript:>>: > >> Hello, >> >> which interests me too much, it would be kind of you if you could post >> the solution . >> >> Are you sure you have all the settings correct >> On 23-Jun-2016 6:12 PM, "Olaf Stolle" <[email protected] <javascript:>> >> wrote: >> >>> Hallo, >>> >>> das interessiert mich auch sehr, es wäre nett von Dir wenn Du die Lösung >>> posten würdest. >>> >>> Bist du sicher das Du alle Einstellungen richtig hast >>> >>> >>> https://console.developers.google.com/apis/credentials?project=region1-0&authuser=0 >>> >>> LG >>> >>> Olaf >>> >>> 2016-06-23 12:35 GMT+02:00 Charles Serra <[email protected] <javascript:>> >>> : >>> >>>> Hello, >>>> >>>> I'm working with dotnet C#, Sheets v4. >>>> I'm the owner of a sheets in Drive, which is shared with some people >>>> who are internal and external of the company. >>>> >>>> We are using service account also with adwords API. >>>> For sheets, we added scope "SheetsService.Scope.SpreadsheetsReadonly" >>>> on the Google Console Admin >>>> >>>> When we are trying to read the sheets with the API, even with my >>>> account (whereas I'm the owner), we got an exception >>>> "*Error:"unauthorized_client", >>>> Description:"Unauthorized client or scope in request.", Uri:""* >>>> >>>> It's working with a public sheets on a personnal drive account, with >>>> the sharing policy "read access to anyone with the link" >>>> >>>> >>>> 1. What am I doing wrong? >>>> 2. Can you confirm it's possible to impersonate a user using the >>>> User property of the ServiceAccountCredential.Initializer object? >>>> >>>> >>>> >>>> The source code: >>>> >>>> >>>> try >>>> >>>> { >>>> >>>> AdWordsAuthenticationConfig auth = Service.Auth; >>>> >>>> >>>> >>>> X509Certificate2 certificate = new X509Certificate2(auth.CertificatePath, >>>> "notasecret", X509KeyStorageFlags.Exportable); >>>> >>>> >>>> >>>> ServiceAccountCredential cred = new ServiceAccountCredential( >>>> >>>> new ServiceAccountCredential.Initializer(auth.ServiceAccountEmail) >>>> >>>> { >>>> >>>> Scopes = new string[] { SheetsService.Scope.SpreadsheetsReadonly }, >>>> >>>> User = "[email protected] <javascript:>", >>>> >>>> }.FromCertificate(certificate) >>>> >>>> ); >>>> >>>> >>>> >>>> SheetsService service = new SheetsService(new BaseClientService. >>>> Initializer >>>> >>>> { >>>> >>>> HttpClientInitializer = cred >>>> >>>> }); >>>> >>>> >>>> >>>> SpreadsheetsResource.ValuesResource.GetRequest request = >>>> service.Spreadsheets.Values.Get(spreadsheetId, range); >>>> >>>> >>>> >>>> ValueRange response = request.Execute(); >>>> >>>> >>>> >>>> return response.Values; >>>> >>>> } >>>> >>>> catch (Exception ex) >>>> >>>> { >>>> >>>> ... >>>> >>>> } >>>> >>>> >>>> Kind regards, >>>> >>>> Charles. >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Google Spreadsheets API" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected] >>>> <javascript:>. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Google Spreadsheets API" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] >>> <javascript:>. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google Spreadsheets API" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] >> <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Google Spreadsheets API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
