1
我有以下代碼:OAuth的谷歌張蟒蛇共享失敗
from oauth2client.service_account import ServiceAccountCredentials
from googleapiclient import discovery
from httplib2 import Http
SCOPES = ['https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scopes=SCOPES)
http_auth = credentials.authorize(Http())
service = discovery.build('sheets', 'v4', credentials=(credentials))
spreadsheet_body = {
'properties': {'title': 'Test Sheet'},
"sheets": [
{
"data": [
{
"startRow": 0,
"startColumn": 0,
"rowData": [
{
"values": [
{
"userEnteredValue": {
"stringValue": "foo"
},
},
{
"userEnteredValue": {
"stringValue": "bar"
},
},
],
},
{
"values": [
{
"userEnteredValue": {
"stringValue": "row2"
},
},
{
"userEnteredValue": {
"stringValue": "row2, col2"
},
},
{
"userEnteredValue": {
"formulaValue": "=HYPERLINK(\"https://www.foo.com\")"
},
},
],
},
],
}
],
}
],
}
request = service.spreadsheets().create(body=spreadsheet_body)
response = request.execute()
print response
這工作,並且紙張用URL創建的,但是,當我嘗試打開URL,我得到:
我的帳戶擁有服務帳戶的所有權限,所以我不認爲這是服務帳戶設置問題,但是,我可能是錯的。
我已經上傳了類似的問題,但我不使用的域。如何有人默認它? –