Google 和 Oauthlib - 范围已随 InstalledAppFlow 发生变化

问题描述

我有以下代码

appflow = flow.InstalledAppFlow.from_client_secrets_file(
    "client_secret.json",scopes=scopes
)

appflow.run_local_server()

credentials = appflow.credentials

但它引发了这个错误

Warning: Scope has changed from "https://www.googleapis.com/auth/drive https://spreadsheets.google.com/Feeds https://www.googleapis.com/auth/gmail.compose" to "https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/gmail.compose".

我检查了 this question,但是在调用不同的方法时会出现错误,因此答案不适用于我的情况。

找不到解决方法

解决方法

好的,错误消息非常简单:我基本上必须用错误消息中指示的新的替换不推荐使用的范围条目:

原始scopes

scopes = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/gmail.compose']

scopes

scopes = ['https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/spreadsheets','https://www.googleapis.com/auth/gmail.compose']