Closed mathtao closed 8 months ago
@mathtao Thanks for submitting the issue. Please remove your username and password from the screenshot attached to this issue as it has sensitive info in the screenshot.
Is this sample app you created yourself? The sample app uses Amplify library to 1) create and sign in user with Amplify Auth and 2) uses the Amplify API category to make a REST api call to to the backend service to create the liveness session. The code is configured in AppDelegate.configureAmplify()
createSession
to call your liveness backend to create a session id or configure the API category to call your backend to create the session id. See documentation on how to setup your API category here: https://docs.amplify.aws/lib/restapi/fetch/q/platform/ios/Ok, thanks. Now there is another question: How can I edit the code and use 'AWSCredentialsProvider' or 'accessKeyId、secretAccessKey' to get the sessionid?
func createSession(_ completion: @escaping (String) -> Void) {
Task { @MainActor in
let request = RESTRequest(
apiName: "liveness",
path: "/liveness/create"
)
do {
let data = try await Amplify.API.post(request: request)
let response = try JSONDecoder().decode(
CreateSessionResponse.self,
from: data
)
completion(response.sessionId)
} catch {
print("Error creating session", error)
}
}
}
@mathtao If you are using Amplify Auth category to create and sign in your user, then the Liveness library will automatically use the AWSCredentialsProvider that is provided by Amplify Auth. If you're not using Amplify Auth, then you can provide your own custom credential provider when constructing the Liveness UI component. See documentation here: https://ui.docs.amplify.aws/swift/connected-components/liveness
Ok, I see If I want to use 'AWSCredentialsProvider' or 'accessKeyId、secretAccessKey' to get the sessionid, how do I need to edit the above code?
@mathtao If you are using Amplify Auth to sign in as a user, you don't need to set or specify the accessKeyId
or secretAccessKey
. The above code can be use as is if you have Amplify Auth and Amplify API configured and you have a REST endpoint that returns the sessionId.
The above code is using Amplify API to make a REST call to an endpoint that will return the session ID. You can not use it or modify it to set the AWSCredentialsProvider
or accessKeyId
or secretAccessKey
Hello I use the sample app code and configure it according to this document "https://ui.docs.amplify.aws/swift/connected-components/liveness"; Except for the following difference, everything else is the same as the document,
$ amplify add auth Do you want to use the default authentication and security configuration? Defau lt configuration
;1、When I click the 'Start Test Server' or 'Start Real Server' button on the demo app interface: Console logs:
Error sign in Developer/Xcode/DerivedData/FaceLivenessDetector-dqubswtsqtikqjexlionhuyqplpn/SourcePackages/checkouts/amplify-swift/Amplify/Categories/API/APICategory.swift:30: Fatal error: No plugins added to API category. 2023-10-13 19:05:33.188709+0800 FaceLivenessDetector[5504:3791289] Developer/Xcode/DerivedData/FaceLivenessDetector-dqubswtsqtikqjexlionhuyqplpn/SourcePackages/checkouts/amplify-swift/Amplify/Categories/API/APICategory.swift:30: Fatal error: No plugins added to API category.
Can you help me see what I need to do to run the app normally for face recognition?
Thanks