Google API의 InsufficientCredentials

5 백일몽

이 오류가 무엇인지 이해하려고합니다.

  File "C:\...\googleapiclient\http.py", line 856, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/drive/v3/files/19XYXTA2xER982xIHnDqH0cOtjBtSZtgC?alt=media returned "Insufficient Permission: Request had insufficient authentication scopes.">

"권한 부족 : 요청에 인증 범위가 부족합니다."는 무엇입니까? 평균?

아래는 전체 코드입니다. credentials.json 및 client_secrets.json이 모두 내 디렉터리에 있습니다.

from __future__ import print_function
import pickle
import os.path
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
import os
g_login = GoogleAuth()
g_login.LocalWebserverAuth()  # This sucker might break [NK]
drive = GoogleDrive(g_login)
#end of tempCodeForEaseOfUse [NK]

# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/documents'] # https://www.googleapis.com/auth/drive.metadata.readonly https://www.googleapis.com/auth/documents.readonly']

# The ID and range of a sample spreadsheet.
SAMPLE_SPREADSHEET_ID = '1eb0DIJ7QglHqCrvIW94MUbMvFdbGKGXBSwaH49ILCvQ/edit?usp=sharing'
SAMPLE_RANGE_NAME = 'Class Data!A2:E'

creds = None
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.pickle'):
    with open('token.pickle', 'rb') as token:
        creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
    if creds and creds.expired and creds.refresh_token:
        creds.refresh(Request())
    else:
        flow = InstalledAppFlow.from_client_secrets_file(
            'credentials.json', SCOPES)
        creds = flow.run_local_server(port=0)
    # Save the credentials for the next run
    with open('token.pickle', 'wb') as token:
        pickle.dump(creds, token)


# TODO: fileID extracted manually, must automate [NK]
fileId = '19XYXTA2xER982xIHnDqH0cOtjBtSZtgC/view?usp=sharing'  # Please set the file ID of text file. [StackTanaike]

sheets = build('sheets', 'v4', credentials=creds)
drive = build('drive', 'v3', credentials=creds)

# Retrieve data from Google Drive and parse data as an array. [StackTanaike]
data = drive.files().get_media(fileId=fileId).execute()

범위가 올바르게 설정되지 않았습니다. SCOPES = ['https:// ...다음으로 교체하십시오 .

SCOPES = ['https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive']

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

PHP의 Google People API

분류에서Dev

Google Scripts의 Aftership API

분류에서Dev

Android의 Google Pay API 통합

분류에서Dev

Apps Script의 Google Docs API

분류에서Dev

json의 Google API 파싱

분류에서Dev

Google App Engine의 검색 API

분류에서Dev

iPhone의 Google 번역 API

분류에서Dev

Perl의 Google Maps API 오류

분류에서Dev

PHP AppEngine의 Google Cloud Vision API

분류에서Dev

Cordova의 Google 번역기 API

분류에서Dev

Google API 장소 자동 완성의 Google API 할당량

분류에서Dev

google api와 google rest api의 차이점은 무엇입니까?

분류에서Dev

Google Docs API의 표 테두리

분류에서Dev

HTML 페이지의 Google Cloud Speech API

분류에서Dev

Google 포토 API의 newMediaItemResults 오류

분류에서Dev

iOS의 Google Places API 자동 완성

분류에서Dev

Google Maps API의 권장 경로 옵션?

분류에서Dev

ASP.NET MVC의 Google API 차트

분류에서Dev

Google의 파노라마 API 사용

분류에서Dev

Google지도 API의 주변 장소

분류에서Dev

중국 IPv6의 Google Geocode API

분류에서Dev

Stateless REST 서버의 Google API 콜백

분류에서Dev

Google Apps Script의 StackExchange API 인증

분류에서Dev

.Net 용 Google Content API의 shipping []. locationGroupName

분류에서Dev

Google Map Engine API의 정보 창

분류에서Dev

Google Map Engine API의 정보 창

분류에서Dev

Google Maps Javascript API v3의 마커

분류에서Dev

PHP 백엔드의 Google Analytics API

분류에서Dev

Google Tango Leibniz API의 색상 이미지