Я пытаюсь отправить запрос на добавление книги на полку в API Google Книг, но получаю ответ 401 с сообщением Login Required
, но пользователь аутентифицирован.
addBookToShelf(shelfId: number, book: Book) {
const headers = new HttpHeaders()
.set('content-type', 'text/plain')
.set('Authorization', `Bearer ${getAccessToken()}`);
const params = new HttpParams().set('volumeId', book.id).set('key', environment.API_KEY);
const url = `https://www.googleapis.com/books/v1/mylibrary/bookshelves/${shelfId}/addVolume`;
return this.http.post<ShelfBooksResponse>(url, {
params,
headers
});
}
return gapi.auth2
.getAuthInstance()
.currentUser.get()
.getAuthResponse().access_token;
};
Что я действительно заметил в запросе, так это то, что авторизация не установлена, но находится в lazyUpdate. https://share.getcloudapp.com/6qu2AzkN