Aws-sdk-ios: Add ability to configure AWSMobileClient via config object rather than awsconfiguration.json

Created on 12 Jul 2019  Â·  8Comments  Â·  Source: aws-amplify/aws-sdk-ios

As reported by @aarons22 in #1609, an app that retrieves configuration values at runtime cannot use AWSMobileClient, because that class always reads from awsconfiguration.json for its configuration values.

This request is to allow AWSMobileClient to be optionally configured via a config object, which could be specified at runtime rather than compile time, similar to what JS does https://aws-amplify.github.io/amplify-js/api/classes/amplify.html#configure.

closing-soon-if-no-response core feature request requesting info

Most helpful comment

So 2.11.0 actually solves the problem of configuring AWSMobileClient at runtime but only once. @palpatim is there an issue to support different configurations? I understand that it must be some limitations, but don't see a reason why client can't be configured multiple times when used exclusively. Something like "configure > initialize > signOut > configure [repeat]".

All 8 comments

Just a watch out - app sync library is dependent on the AWSCore, which is where the Cognito stuff lives. Version was recently bumped to 2.10.0, but app sync’s dependency to AWSCore is set at ~>2.9, which means we’ll likely run into issues updating to the new Cognito stuff when it’s available if that remains.

Trying to prevent the scenario where this feature is ready and we are unable to use the update because of the app sync dependency,

We released this in https://github.com/aws-amplify/aws-sdk-ios/releases/2.11.0

Please let us know if you have any problems with this feature.

I have detected a bug while using the new initializer released in 2.11.0. I have opened an issue #1939

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

So 2.11.0 actually solves the problem of configuring AWSMobileClient at runtime but only once. @palpatim is there an issue to support different configurations? I understand that it must be some limitations, but don't see a reason why client can't be configured multiple times when used exclusively. Something like "configure > initialize > signOut > configure [repeat]".

Sorry to necro this issue, but I'm seeing the following issue:

I'm configuring my AWSMobileClient in memory, however, when using the APIGateway, I'm getting the following error:

some : AWSMobileClientError
    â–¿ cognitoIdentityPoolNotConfigured : 1 element
      - message : "There is no valid cognito identity pool configured in `awsconfiguration.json`."

From what I can tell, this is because AWSMobileClient.credentials() task fails. If I call this method separately, I see the same above error (and I see in the source code of the APIGatewayClient that that's the method it calls.

Any idea on why this is? I'm going to keep investigating, but this is a pretty big blocker right now

@cody1024d Could you open a new issue with whatever details your investigation reveals (especially repro steps and your configuration)? What we usually do for in-memory configs is to generate our desired config via Amplify CLI, then translate that to an in-memory structure--the structure of the Auth stanzas can vary depending on the auth methods you select.

@mrublev Could you open a feature request with the details of your use case? The existing system definitely supports signing in and out with a new user, but such a flow wouldn't require a re-configuration.

Was this page helpful?
0 / 5 - 0 ratings