-
Our use case is very simple - a macOS application that needs to authenticate and perform some basic S3 actions. The trick is that the authentication is happening via a different system that will vend the above info. We need to be able to collect this info in the UI of our application and use it to configure the S3Client. Is this possible with this SDK? We would like to use this SDK over the previous iOS SDK (which I previously hacked to make work on macOS), but if it will not be possible to supply these keys somehow at runtime other than env vars, this whole SDK will be a non-starter for us. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Here is a code sample that allows you to supply your own credentials programmatically. The example is for STS, but S3 should configure the exact same way. import AWSSTS
import SmithyIdentity
let region = "us-east-1" // or whatever region you are using
let credentials = AWSCredentialIdentity(accessKey: "", secret: "", expiration: nil, sessionToken: nil) // your credentials here
let identityResolver = try StaticAWSCredentialIdentityResolver(credentials)
let config = try await STSClient.STSClientConfiguration(awsCredentialIdentityResolver: identityResolver, region: region)
let client = STSClient(config: config)
// now use your client to call APIs. Not sure where you are obtaining your credentials, but we don't recommend the use of long-lived AWS credentials with macOS apps (or apps on other Apple platforms, for that matter). Instead, we recommend using an identity provider such as AWS Cognito to obtain temporary AWS credentials based on a previously-authenticated, trusted identity. |
Beta Was this translation helpful? Give feedback.
Here is a code sample that allows you to supply your own credentials programmatically. The example is for STS, but S3 should configure the exact same way.