我正在使用XCode 7.3在Swift中開發iOS應用程序。該應用程序與DynamoDB數據庫通信,允許用戶讀取和寫入數據。最近,我更新了我的Pod,其中包括,AWSCognito
,AWSCognitoIdentityProvider
和其他AWS吊艙。我還建立了一個新的用戶羣,根據此頁面上的說明:AWS Cognito錯誤:未設置身份驗證代理
由於以下這些指令的一部分,我把下面的代碼在AppDelegate類的didFinishLaunchingWithOptions方法:
let serviceConfiguration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: nil)
let userPoolConfiguration = AWSCognitoIdentityUserPoolConfiguration(clientId:APP_CLIENT_ID, clientSecret: appSecret, poolId: USER_POOL_ID)
AWSCognitoIdentityUserPool.registerCognitoIdentityUserPoolWithConfiguration(serviceConfiguration, userPoolConfiguration: userPoolConfiguration, forKey: USER_POOL_NAME)
let pool = AWSCognitoIdentityUserPool(forKey:USER_POOL_NAME)
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: IDENTITY_POOL_ID, identityProviderManager:pool)
let configuration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
通過從AWS控制檯開始導航到Cognito,Federated Identities,我按照說明創建的身份池,「編輯身份池」,然後複製「身份池ID」旁邊顯示的字符串,我獲得了IDENTITY_POOL_ID
的值。通過在同一頁面上展開「Authentication Providers」並選擇「Cognito」選項卡,我獲得了APP_CLIENT_ID
的值。對於USER_POOL_NAME
,我在此頁面上使用了「身份池名稱」,對於USER_POOL_ID
,我使用了「身份驗證提供程序」下列出的「用戶池ID」值。我不清楚我是否正確設置了這些值,因爲我不完全確定開發者指南的哪些值正在說我應該使用。
更新吊艙和完成這些修改後,當我運行的應用程序,我看到的錯誤:
[Error] AWSCredentialsProvider.m line:569 | __44-[AWSCognitoCredentialsProvider credentials]_block_invoke.345 | Unable to refresh. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityProviderErrorDomain Code=-1000 "Authentication delegate not set" UserInfo={NSLocalizedDescription=Authentication delegate not set}]
這也是現在無法訪問DynamoDB數據,雖然應用程序仍然沒有啓動。我懷疑部分問題是我的DynamoDB數據庫不在USEast中,但我不確定這是否會導致此錯誤。除了更改AppDelegate中的代碼外,我還試圖查找可能的原因,但錯誤仍然相同。我可以調查哪些可能的原因?如果它有所不同,我試圖讓應用程序授權用戶,除了恢復DynamoDB功能,並且我想在解決此問題的過程中完成這兩個操作。
謝謝,這些鏈接非常有幫助。但是,現在我已經設置了登錄/註冊屏幕,當我輸入信息並嘗試註冊我的應用時,出現新的錯誤:{「__ type」:「ResourceNotFoundException」,「message」:「用戶池客戶端####不存在。「}這與我用於APP_CLIENT_ID的值相同,我從」身份驗證提供程序「下的」應用程序客戶端ID「字段複製它,但它在其他地方看起來並不存在。這應該與我在用戶池或我的聯合身份池中看到的其他值匹配嗎?創建我的泳池時,我應該從哪裏獲得這個價值? – user3726962
沒關係,我更仔細地查看了用戶池控制檯,發現了我正在尋找的值。 – user3726962