Skip to content

There's no documentation on how to refresh/update the credentials. #460

Closed
@raRaRa

Description

Hi. I'm using this library in a React project to have the ability to subscribe to events. I use the cognito identity method on the browser side to get credentials. It was very simple to do in v1 but now I'm trying to upgrade to v2. In v1 I could do updateWebSocketCredentials to update the credentials, but I can't find anything similar in v2.

I've tried various methods in v2, such as using new_with_websockets that accepts options:

let config = iot.AwsIotMqttConnectionConfigBuilder.new_with_websockets({
    region: awsConfiguration.region,
    service: "wss",
    credentials_provider: {
      getCredentialsAsync: async () => {
        const credentials: any = await getCredentialsAsync();
        if (credentials) {
          expiration = credentials.Expiration;
          return {
            accessKeyId: credentials.AccessKeyId,
            secretAccessKey: credentials.SecretKey,
            sessionToken: credentials.SessionToken,
            expiration: credentials.Expiration,
          };
        }
        return null;
      },
    },
  })

But that doesn't seem to work.

Is there no method to update the credentials when they expire? I found one React example that uses something called .with_credential_provider that doesn't seem to exist any longer.

.with_credential_provider(provider)

Any help would be appreciated.

Links

.with_credential_provider(provider)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    documentationThis is a problem with documentation.p3This is a minor priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions