gpt4 book ai didi

Swift AWS Cognito 错误 : Authentication delegate not set

转载 作者:行者123 更新时间:2023-11-30 11:00:55 24 4
gpt4 key购买 nike

我正在使用 swift 开发一个应用程序,我使用 AWS 移动服务进行身份验证,并使用 AWS Lambda 进行一些后端处理。我一切正常,有一天(离开应用程序一个月左右后),它开始抛出此错误:

 GetId failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityProviderErrorDomain Code=-1000 "Authentication delegate not set" UserInfo {NSLocalizedDescription=Authentication delegate not set}]
Unable to refresh. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityProviderErrorDomain Code=-1000 "Authentication delegate not set"

这简直要了我的命,因为它已经在工作了。可以改变什么?

在 appDelegate 中,我有:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {

// Uncomment to turn on logging, look for "Welcome to AWS!" to confirm success
AWSDDLog.add(AWSDDTTYLogger.sharedInstance)
AWSDDLog.sharedInstance.logLevel = .error

// Instantiate AWSMobileClient to get AWS user credentials
return AWSMobileClient.sharedInstance().interceptApplication(application, didFinishLaunchingWithOptions:launchOptions)
}

它实际上在我进行任何调用之前抛出错误,所以我认为上面的行可能会触发问题?

要登录,我在主视图 Controller 中执行以下操作:

override func viewDidLoad() {
super.viewDidLoad()

if !AWSSignInManager.sharedInstance().isLoggedIn {
presentAuthUIViewController()
}
else{
getCredentials()
}
...
}

func presentAuthUIViewController() {
let config = AWSAuthUIConfiguration()
config.enableUserPoolsUI = true
config.backgroundColor = UIColor.white
config.logoImage = #imageLiteral(resourceName: "logoQ")
config.isBackgroundColorFullScreen = true
config.canCancel = true

AWSAuthUIViewController.presentViewController(
with: self.navigationController!,
configuration: config, completionHandler: { (provider:
AWSSignInProvider, error: Error?) in
if error == nil {
self.getCredentials()
} else {
// end user faced error while loggin in, take any required action here.
}
})
}

func getCredentials() {
let serviceConfiguration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: nil)
let userPoolConfiguration = AWSCognitoIdentityUserPoolConfiguration(clientId: "id",
clientSecret: "secret",
poolId: "id")
AWSCognitoIdentityUserPool.register(with: serviceConfiguration, userPoolConfiguration: userPoolConfiguration, forKey: "key")
let pool = AWSCognitoIdentityUserPool(forKey: "key")
if let username = pool.currentUser()?.username {
userName = username
}

它登录,我检索用户名。

有什么建议吗?我按照其他帖子中的一些说明进行操作,但它们不起作用,而且最让我不安的是它起作用了!

提前致谢

最佳答案

我认为这意味着您的刷新 token 已过期。

关于Swift AWS Cognito 错误 : Authentication delegate not set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53374322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com