These utilities help you authenticate when when making Amazon Location Service API calls from their iOS applications. This specifically helps when using Amazon Cognito as the authentication method.
- Go to File -> Add Package Dependencies in your XCode project.
- Type the package URL (https://github.com/aws-geospatial/amazon-location-mobile-auth-sdk-ios/) into the search bar and press the enter key.
- Select the "amazon-location-mobile-auth-sdk-ios" package and click on "Add Package".
- Select the "AmazonLocationiOSAuthSDK" package product and click on "Add Package".
After installing the library, import the AuthHelper class in an activity:
import AmazonLocationiOSAuthSDK
import AWSLocationXCF
You can create an AuthHelper and use it with the AWS SDK:
// Create an authentication helper using credentials from Cognito
func exampleCognitoLogin() {
let authHelper = AuthHelper()
let locationCredentialsProvider = authHelper.authenticateWithCognitoIdentityPool(identityPoolId: "My-Cognito-Identity-Pool-Id", region: "us-east-1")
let locationClient = authHelper.getLocationClient()
}
// Create an authentication helper using credentials from any AWS-Swift-SDK [Credentials Provider](https://github.com/awslabs/aws-crt-swift/blob/main/Source/AwsCommonRuntimeKit/auth/credentials/CredentialsProvider.swift)
func exampleCognitoLogin() {
let authHelper = AuthHelper()
let credentialProvider = try CredentialsProvider(source: .static(accessKey: "My-AWS-AccessKey", secret: "My-AWS-Secret", sessionToken: "My-AWS-SessionToken", shutdownCallback: {/*Perform post shutdown operation here*/}))
let locationCredentialsProvider = authHelper.authenticateWithCredentialsProvider(credentialsProvider: credentialProvider)
let locationClient = authHelper.getLocationClient()
}
See CONTRIBUTING for more information.
The best way to interact with our team is through GitHub. You can open an issue and choose from one of our templates for bug reports, feature requests or guidance. If you have a support plan with AWS Support, you can also create a new support case.
We welcome community contributions and pull requests. See CONTRIBUTING.md for information on how to set up a development environment and submit code.
The Amazon Location Service Mobile Authentication SDK for iOS is distributed under the Apache License, Version 2.0, see LICENSE.txt and NOTICE.txt for more information.