我创建了一个新项目并生成了一个新的 OAuth 2.0 客户端 ID,但凭据中似乎没有任何可用的客户端密码。OAuth 2.0 for Mobile & Desktop Apps:Step 5 的文档指出需要提供此参数。
这是一个请求:
▿ https://oauth2.googleapis.com/token
▿ url : Optional<URL>
▿ some : https://oauth2.googleapis.com/token
- _url : https://oauth2.googleapis.com/token
- cachePolicy : 0
- timeoutInterval : 30.0
- mainDocumentURL : nil
- networkServiceType : __C.NSURLRequestNetworkServiceType
- allowsCellularAccess : true
▿ httpMethod : Optional<String>
- some : "POST"
▿ allHTTPHeaderFields : Optional<Dictionary<String, String>>
▿ some : 1 element
▿ 0 : 2 elements
- key : "Content-Type"
- value : "application/x-www-form-urlencoded; charset=utf-8"
▿ httpBody : Optional<Data>
▿ some : 372 bytes
- count : 372
▿ pointer : 0x00007fce7b5186f0
- pointerValue : 140524808931056
- httpBodyStream : nil
- httpShouldHandleCookies : true
- httpShouldUsePipelining : false
请求正文数据包含与用于成功获取有效授权码的 client_id、redirect_uri 和 code_verifier 完全相同的参数值。
任何没有 client_secret 或使用空字符串的
请求都会返回 400。任何使用除空字符串以外的任何内容的请求都会返回 401,invalid_client 错误。
这是文档的链接:
https ://developers.google.com/identity/protocols/oauth2/native-app#ios
这是该项目的链接:
https ://github.com/PJCSpencer/SwiftOAuth2Client
有任何想法吗?