capless / warrant

Python library for using AWS Cognito. With support for SRP.
Apache License 2.0
468 stars 192 forks source link

NoRegionError: No region specify error is coming at the time of creation of cognito #39

Closed rizwans-cuelogic closed 7 years ago

polendri commented 7 years ago

You've gotta tell Boto3 what region to use somehow (the region in which your Cognito user pool exists); either by passing it as an argument to Cognito or AWSSRP in this library, or setting the AWS_DEFAULT_REGION environment variable, or defining an AWS config file.

rizwans-cuelogic commented 7 years ago

I passed region name to cognito constructor but same exception is coming

atwalsh commented 7 years ago

I am having the same issue as @rizwans-cuelogic. Passing the user_pool_region argument returns an error.

u = Cognito('your-user-pool-id', 'your-client-id', user_pool_region='us-east-1')

Returns this error:

botocore.exceptions.NoRegionError: You must specify a region.

  EDIT: I fixed this by passing my AWS access and secret key. Maybe there should be a warning message if no AWS access key or secret key is passed to the constructor?

faizans-cuelogic commented 7 years ago

@atwalsh04 your instance functions are working properly? because in cognito constructor code there is nothing given about AWS access and secret key as parameter.

atwalsh commented 7 years ago

@faizans-cuelogic Yes, the arguments for this are access_key and secret_key.

This line is from the Cognito constructor:

if access_key and secret_key:
    self.client = boto3.client('cognito-idp',
        aws_access_key_id=access_key,
        aws_secret_access_key=secret_key,
        region_name=self.user_pool_region
        )
else:
    self.client = boto3.client('cognito-idp')

If you do not pass these to the constructor, boto3 looks for AWS credentials as defined in the boto3 Credentials Configuration.