Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 请求的身份验证作用域不足_Ios_Swift_Google Sheets_Google Sheets Api - Fatal编程技术网

Ios 请求的身份验证作用域不足

Ios 请求的身份验证作用域不足,ios,swift,google-sheets,google-sheets-api,Ios,Swift,Google Sheets,Google Sheets Api,我正试图从我的swift项目中写一份谷歌工作表 我的播客文件看起来像: platform :ios, '8.0' target 'MyApp' do pod 'GoogleAPIClientForREST/Sheets', '~> 1.2.1' pod 'GoogleSignIn', '~> 4.1.1' pod 'Alamofire' pod 'GoogleAPIClientForREST' end 我已经在开发人员控制台上启用了Goog

我正试图从我的swift项目中写一份谷歌工作表

我的播客文件看起来像:

platform :ios, '8.0'
target 'MyApp' do
     pod 'GoogleAPIClientForREST/Sheets', '~> 1.2.1'
     pod 'GoogleSignIn', '~> 4.1.1'
     pod 'Alamofire'
     pod 'GoogleAPIClientForREST'
 end
我已经在开发人员控制台上启用了Google Drive和Google Sheets API,并完成了Google登录所需的集成步骤。我的登录部分工作正常,我能够验证我是否已登录

我试着这样写在纸上:

let sheetID = "*************"
    let range = "A3:B4"
    let requestParams = [
        "values": [
            ["hi1", "hi2"],
            ["hi3", "hi4"]
            ]
        ]
    let accessToken = GIDSignIn.sharedInstance().currentUser.authentication.accessToken!
    let header = ["Authorization":"Bearer \(accessToken)"]
    let requestURL = "https://sheets.googleapis.com/v4/spreadsheets/\(sheetID)/values/\(range)?valueInputOption=USER_ENTERED"
    let req = Alamofire.request(requestURL, method: .put, parameters: requestParams, encoding: JSONEncoding.default, headers: header)
    req.responseJSON { response in debugPrint(response) }
我从这里引用了

现在,我遇到的问题是,当我运行代码试图写入工作表时,我得到了这个响应(工作表ID已被我故意删除):

[请求]:放置https://sheets.googleapis.com/v4/spreadsheets/**********/值/A3:B4?值输入选项=用户输入
[请求机构]:
{“值”:[[“hi1”,“hi2”],[“hi3”,“hi4”]}
[答复]:{URL:https://sheets.googleapis.com/v4/spreadsheets/*******/values/A3:B4?valueInputOption=用户输入}{状态代码:403,标题{
“Alt Svc”=(
“h3-Q050=\”:443\“ma=2592000,h3-29=\”:443\“ma=2592000,h3-T051=\”:443\“ma=2592000,h3-T050=”:443\“ma=2592000,h3-Q046=”:443\“ma=2592000,h3-Q043=”:443\“ma=2592000,quic=”:443\“ma=2592000;v=”46,43“
);
“缓存控制”=(
私有的
);
“内容编码”=(
gzip
);
“内容长度”=(
137
);
“内容类型”=(
“application/json;charset=UTF-8”
);
日期=(
“2020年11月10日星期二14:16:00 GMT”
);
服务器=(
ESF
);
变化=(
起源,
“X源”,
推荐人
);
“Www认证”=(
“承载域=\”https://accounts.google.com/\,错误=\“范围不足”,范围=\“https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.resource https://www.googleapis.com/auth/spreadsheets https://spreadsheets.google.com/feeds https://spreadsheets.google.com/feeds/ http://spreadsheets.google.com/feeds http://spreadsheets.google.com/feeds/ https://spreadsheets.google.com/feeds/spreadsheetshttps://spreadsheets.google.com/feeds/spreadsheets/private/full http://spreadsheets.google.com/feeds/spreadsheets/private/full https://spreadsheets.google.com/feeds/worksheets/ https://spreadsheets.google.com/tq https://spreadsheets.google.com/feeds/list/ https://spreadsheets.google.com/feeds/worksheet/ https://spreadsheets.google.com/feeds/cell/\“”
);
“x帧选项”=(
萨米奥里金
);
“x-xss-protection”=(
0
);
} }
[答复机构]:
{
“错误”:{
“代码”:403,
“消息”:“请求的身份验证作用域不足。”,
“状态”:“权限被拒绝”
}
}
[结果]:成功
[时间线]:时间线:{“请求开始时间”:626710559.941,“初始响应时间”:626710560.249,“请求完成时间”:626710560.250,“序列化完成时间”:626710560.252,“延迟”:0.308秒,“请求持续时间”:0.310秒,“序列化持续时间”:0.001秒,“总持续时间”:0.311秒}
在研究这些内容的过程中,我也发现了一些我认为可以解决我问题的方法,但当我尝试添加
GIDSignIn.sharedInstance()?.scopes=[KgtlRauthScopeSheetsPreadsheets]
时,它告诉我
在范围中找不到“KgtlRauthScopesPreadsheets”

我觉得在这一点上,我被困在了下一步可以尝试的东西上。任何建议都将不胜感激

我需要补充:

GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/drive")
            GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/drive.file")
            GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/drive.resource")
            GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/spreadsheets")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/spreadsheets")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/spreadsheets/private/full")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/worksheets/")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/tq")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/list/")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/cell/")
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/drive")
            GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/drive.file")
            GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/drive.resource")
            GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/spreadsheets")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/spreadsheets")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/spreadsheets/private/full")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/worksheets/")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/tq")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/list/")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds")
            GIDSignIn.sharedInstance().scopes.append("https://spreadsheets.google.com/feeds/cell/")