aws-amplify / amplify-swift

A declarative library for application development using cloud services.
Apache License 2.0
447 stars 193 forks source link

Can't initialize AWSAuthSignInOptions for sending validationData with SignIn request #654

Closed angelucas8080 closed 4 years ago

angelucas8080 commented 4 years ago

Hi,

I am using Lambda trigger with Cognito and I want to send clientMetadata with the sign in request (InitiateAuth).

From here:

https://github.com/aws-amplify/amplify-ios/blob/d045aa4066b7dfac758ad971a4093be8536071ea/AmplifyPlugins/Auth/AWSCognitoAuthPlugin/Dependency/AuthenticationProviderAdapter%2BSignIn.swift#L25

I figured that I should create my validataion data in the metadata property of AWSAuthSignInOptions, and then use it in Amplify.Auth.signIn() as follows:

let awsAuthSignInOptions = AWSAuthSignInOptions(validationData: nil, metadata: ["mydata": "myvalue"])
let options = AuthSignInOperation.Request.Options(pluginOptions: awsAuthSignInOptions)

_ = Amplify.Auth.signIn(username: username, password: password, options: options) { result in

But when I do that, Xcode shows the following error:

'AWSAuthSignInOptions' initializer is inaccessible due to 'internal' protection level

that suggests that AWSAuthSignInOptions is not supposed to be used outside of the package. (Ref. https://stackoverflow.com/questions/54673224/public-struct-in-framework-init-is-inaccessible-due-to-internal-protection-lev)

In that case, how should I set my validation data?

Thanks.

ruiguoamz commented 4 years ago

Hi, @angelucas8080. Thanks for reaching out. It is a bug in our code and the fix is in progress

drochetti commented 4 years ago

Hey @angelucas8080 1.0.5 was release and your issue should be fixed. Feel free to re-open if you're still facing the same issue after updating to the latest release.

angelucas8080 commented 4 years ago

Thanks! I confirmed that this works for me!