В настоящее время я пытаюсь подключиться к API Google Таблиц. Я использую ключ служебной учетной записи, поэтому Salesforce может извлекать данные из Google Таблиц без необходимости ручной авторизации каждый раз при отправке запроса.
Я нахожусь на этапе настройки ключа учетной записи службы и успешно отправляю ему запрос для получения кода доступа.
Затем я пытаюсь запросить API, используя следующий класс:
Код: Выделить всё
/****** API CALLOUT *******/
public static HttpResponse googleSheetsCallout (){
//the below line provides a string containing access token to google
string accessCode = getAccessToken();
//I found this endpoint structure online, this may be why my script
//isn't working. However, I am struggling to find the alternative.
string endpoint = 'https://sheets.googleapis.com/v4/spreadsheets/params=[SPREADSHEET ID GOES HERE]/values/[RANGE GOES HERE]?access_token=';
httpRequest req = new httpRequest();
req.setEndpoint(endpoint+accessCode);
req.setMethod('GET');
req.setTimeout(120000);
httpResponse res = new http().send(req);
System.debug ('res is ' +res);
return res;
}
Код: Выделить всё
|CALLOUT_RESPONSE|[71]|System.HttpResponse[Status=Forbidden, StatusCode=403]
|USER_DEBUG|[72]|DEBUG|res is System.HttpResponse[Status=Forbidden, StatusCode=403]
Подробнее здесь: https://stackoverflow.com/questions/445 ... ccount-key
Мобильная версия