- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们正在实现 Apple 对用户删除施加的新 guidelines。我正在使用 firebase 进行身份验证。我正在创建一个用户帐户。这里没问题。但我无法删除使用苹果登录的用户。我收到错误。我正在使用此 api 删除 token revoke API 。我是 swift 的新手。我找不到问题
这是我的登录码。它工作正常:
class SignUpNewUser: NSObject {
/// apple
var currentNonce: String? // fileprivate
}
extension SignUpNewUser : ASAuthorizationControllerPresentationContextProviding{
func Apple() {
let nonce = randomNonceString()
currentNonce = nonce
let appleIDProvider = ASAuthorizationAppleIDProvider()
let request = appleIDProvider.createRequest()
request.requestedScopes = [.fullName, .email]
request.nonce = sha256(nonce)
let authorizationController = ASAuthorizationController(authorizationRequests: [request])
authorizationController.delegate = self
authorizationController.presentationContextProvider = self
authorizationController.performRequests()
}
private func sha256(_ input: String) -> String {
let inputData = Data(input.utf8)
let hashedData = SHA256.hash(data: inputData)
let hashString = hashedData.compactMap {
return String(format: "%02x", $0)
}.joined()
return hashString
}
private func randomNonceString(length: Int = 32) -> String {
precondition(length > 0)
let charset: Array<Character> =
Array("0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._")
var result = ""
var remainingLength = length
while remainingLength > 0 {
let randoms: [UInt8] = (0 ..< 16).map { _ in
var random: UInt8 = 0
let errorCode = SecRandomCopyBytes(kSecRandomDefault, 1, &random)
if errorCode != errSecSuccess {
fatalError("Unable to generate nonce. SecRandomCopyBytes failed with OSStatus \(errorCode)")
}
return random
}
randoms.forEach { random in
if length == 0 {
return
}
if random < charset.count {
result.append(charset[Int(random)])
remainingLength -= 1
}
}
}
return result
}
}
extension SignUpNewUser: ASAuthorizationControllerDelegate {
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
guard let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential else {
dataSource?.endSignUpWithError(error: eLogin.authorizationNotFound.error(), method: .apple)
return
}
guard let nonce = currentNonce else {
fatalError("Invalid state: A login callback was received, but no login request was sent.")
}
// JWT
guard let appleIDToken = appleIDCredential.identityToken else {
dataSource?.endSignUpWithError(error: eLogin.identityToken.error(), method: .apple)
return
}
guard let idTokenString = String(data: appleIDToken, encoding: .utf8) else {
mylog(eLogin.serializeToken.error(), appleIDToken.debugDescription)
dataSource?.endSignUpWithError(error: eLogin.serializeToken.error(), method: .apple)
return
}
let credential = OAuthProvider.credential(withProviderID: "apple.com", idToken: idTokenString, rawNonce: nonce)
@AppStorage("JWt_client_secret") var client_secret: String = ""
@AppStorage("apltoken") var apple_token: String = ""
client_secret = nonce
apple_token = idTokenString
signInFirebaseAccount(credential, appleIDCredential:appleIDCredential)
}
/// signup tamam firebase bağla hesabı
private func signInFirebaseAccount(_ credential: AuthCredential, appleIDCredential: ASAuthorizationAppleIDCredential) {
Auth.auth().signIn(with: credential) { (authResult, error) in
if let error = error {
self.dataSource?.endSignUpWithError(error: error , method: .apple)
}else{
guard let user = authResult?.user else {
self.dataSource?.endSignUpWithError(error: eLogin.kayitHatasi.error(), method: .apple)
return
}
// JWT
guard let appleIDToken = appleIDCredential.identityToken else {
print("hata 5")
return
}
guard let idTokenString = String(data: appleIDToken, encoding: .utf8) else {
print("hata 6")
return
}
guard let nonce = self.currentNonce else {
fatalError("Invalid state: A login callback was received, but no login request was sent.")
}
@AppStorage("JWt_client_secret") var client_secret: String = ""
@AppStorage("apltoken") var apple_token: String = ""
client_secret = nonce
apple_token = idTokenString
self.createNewUser(user: user, method: .apple)
}
}
}
}
我正在使用此代码删除帐户。这是行不通的。我正在添加运行代码后获得的控制台图像。
extension SignUpNewUser{
func deleteAppleAccount() {
@AppStorage("JWt_client_secret") var client_secret: String = ""
@AppStorage("apltoken") var apple_token: String = ""
let urlString = "https://appleid.apple.com/auth/revoke"
let url = NSURL(string: urlString)!
let paramString: [String : Any] = [
"client_id": "com.MyCompany.Name",
"client_secret": client_secret,
"token": apple_token
]
let request = NSMutableURLRequest(url: url as URL)
request.httpMethod = "POST"
request.httpBody = try? JSONSerialization.data(withJSONObject:paramString, options: [.prettyPrinted])
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
// request.setValue("application/json", forHTTPHeaderField: "Accept")
let task = URLSession.shared.dataTask(with: request as URLRequest) { (data, response, error) in
guard
let response = response as? HTTPURLResponse,
error == nil
else { // check for fundamental networking error
print("error", error ?? URLError(.badServerResponse))
return
}
guard (200 ... 299) ~= response.statusCode else { // check for http errors
print("statusCode should be 2xx, but is \(response.statusCode)")
print("response = \(response)")
return
}
if let error = error {
print(error)
}else{
print("deleted accont")
}
}
task.resume()
}
}
控制台输出:
statusCode should be 2xx, but is 400
response = <NSHTTPURLResponse: 0x2815e5e00> { URL: https://appleid.apple.com/auth/revoke } { Status Code: 400, Headers {
"Cache-Control" = (
"no-store"
);
Connection = (
"keep-alive"
);
"Content-Length" = (
26
);
"Content-Type" = (
"application/json;charset=ISO-8859-1"
);
Date = (
"Sat, 28 May 2022 12:07:51 GMT"
);
Pragma = (
"no-cache"
);
Server = (
Apple
);
} }
我哪里错了?我找不到任何关于它的教程。帐户删除选项将在当月 30 日之后强制执行。我现在需要解决这个问题:(
最佳答案
如果您不刷新 token 用户,您应该试试这个...
let paramString: [String : Any] = [
"client_id": "com.MyCompany.Name",
"client_secret": client_secret,
"token": apple_token,
"token_type_hint": "access_token"
]
如果你这样做
let paramString: [String : Any] = [
"client_id": "com.MyCompany.Name",
"client_secret": client_secret,
"token": apple_token,
"token_type_hint": apple_typeToken
]
其中 apple_typeToken 可以是“access_token”或“refresh_token”
你应该像这样编辑你的请求。httpMethod
关于ios - 我无法删除使用苹果登录的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72415745/
是否可以为字符串对象定义代数? 例如: 苹果 + 苹果 = 2 个苹果 苹果 + 橙 = 橙 + 苹果 苹果 + 3.5 苹果 = 4.5 苹果 是否有内置函数可以做到这一点?是否有必要创建类结构?
我将为餐厅创建一个 iOS 应用程序,这样您就可以通过该应用程序轻松支付食物费用。所以看看苹果的规则: https://developer.apple.com/app-store/review/gui
当我通过在断点处停止来调试程序时,队列和堆栈显示为 size=0(当它们不是时),但其他变量(如 vector )工作正常。 MacOS 10.14.1 Mojave Cmake 3.12.3 Xco
我正在尝试在圆形图上重现圆形末端,但我自己无法解决。 我试过谷歌但找不到准确的术语来重新创建它。 任何人都可以引导我朝着正确的方向前进或告诉我我在寻找什么吗? 我想要一个看起来像这样的圆形图 http
出于某种原因,我的脚本拒绝直接从 Text Wrangler 运行,但在导入到终端时运行正常。 import math def main(): print("This program find
我在 mac 上,我写了很多 python 脚本。 每次我需要运行它们时,我都必须输入“python script_name.py”。有什么方法可以让我只需要键入“p script_name.py”吗
我刚刚在 Mac OS X (Snow Leopard) 上安装了 python 2.6,当我启动 IDLE 时它一直在退出! 我通过以下方式删除了所有 python 安装:rm -rf/Librar
北京时间12月18日晚间消息,据国外媒体报道,亚马逊、谷歌和苹果公司周三达成一项罕见的合作伙伴关系,旨在打造智能家居新标准,让消费者使用起来更方便。 当前,亚马逊、谷歌和苹果都在积极争抢智能家居用
我一直在研究我们是否可以创建一个应用程序,可以在苹果的 native 媒体播放器中播放 protected DRM 视频文件。但我可以收集到的是,苹果将不允许受 DRM 保护的视频文件通过媒体播放器进
个人开发者通常需要多长时间才能被接受加入开发者计划? 我今天付了微薄的钱,但我感到不耐烦。 最佳答案 第二天我就被录取了,感觉很棒。还带着我的照片和那封电子邮件;-) 关于iphone - 苹果 iP
我是 CIT 的理学学士学生。我有一个项目,我想在某种主机/客户端中使用 Java 小程序和 JDBC。 我的小程序在本地主机上正常工作,但是当我将其部署到 apache Web 服务器上时,我失去了
一周前,我在代码中编写了一个名为 getline 的函数,但该函数不起作用。从那时起,每当我将函数命名为 getline 并尝试编译它时,它都不起作用。如果我将函数名称更改为其他名称,它会再次起作用。
我在使用苹果时遇到问题 examples对于 vDSP。我尝试了所有这些,但最后我需要卷积样本。我什至无法通过链接器获取它: Undefined symbols for architecture i3
我正在尝试将 Apple map 集成到我的 iPhone 应用程序中,以显示两个位置之间的路线。但它不会显示任何路线,并且会简单地在控制台中打印大量消息。 我位于印度孟买。当我尝试在 iPhone
也许你们都看到了Apple’s HTML5 showcase .问题是,他们没有在网上提供任何可下载的内容,对吗? 有没有人找到像 theirs 这样的 360 示例?我们可以按原样下载和使用,而不是
friend 们,请帮忙! 我不知道如何做“wait.until”。 我将 Appium 与 UIAutomator 结合使用。 我的测试会等到新应用程序的页面加载完毕,并且文本字段中的“文本 1”将
Android 比较 2 个图像以使用位图代码并告诉水果类别是水果(苹果/香蕉)还是不是水果。 我有问题与 Bitmap 和 BitmapFactory 比较有运行时错误,我有问题的解决方案。 act
Apple 有一个特殊的 URL,可用于指向物理位置的超链接,触发本地 map 应用程序启动并呈现指定位置: http://maps.apple.com/?q=SEARCH According to
我正在使用 MKMapView 将本地 map 添加到我的 iOS 应用程序。我只想确定是否需要任何类型的身份验证 key 或应用程序 ID?我会将此应用程序上传到 Apple Store。 最佳答案
你好,我想在苹果 map 上做针点聚类。它的可能解决方案是什么。现在我的屏幕上显示了一个针点的苹果 map 。 Pin point分组后的代码是什么。提前致谢 最佳答案 在 map 上聚类/显示大量点
我是一名优秀的程序员,十分优秀!