Skip to content

Commit

Permalink
updated doc string for update_profile and add arguments sections to a…
Browse files Browse the repository at this point in the history
… couple of methods in the README.md
  • Loading branch information
bjinwright committed Apr 11, 2017
1 parent a53cb08 commit d2b5371
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 10 deletions.
77 changes: 68 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,30 @@ If this method call succeeds the instance will have the following attributes **i
from warrant import Cognito

u = Cognito('your-user-pool-id','your-client-id',
username='bob',password='bobs-password')
username='bob')

u.authenticate()
u.authenticate(password='bobs-password')
```

##### Arguments

- **password:** - User's password

#### Admin Authenticate

Authenticate the user using admin super privileges

```python
from warrant import Cognito

u = Cognito('your-user-pool-id','your-client-id',
username='bob')

u.admin_authenticate(password='bobs-password')
```

- **password:** User's password

#### Change Password ####

Changes the user's password
Expand All @@ -138,6 +157,11 @@ u = Cognito('your-user-pool-id','your-client-id',
u.change_password('previous-password','proposed-password')
```

##### Arguments

- **previous_password:** - User's previous password
- **proposed_password:** - The password that the user wants to change to.

#### Confirm Sign Up ####

Use the confirmation code that is sent via email or text to confirm the user's account
Expand All @@ -150,6 +174,11 @@ u = Cognito('your-user-pool-id','your-client-id')
u.confirm_sign_up('users-conf-code',username='bob')
```

##### Arguments

- **confirmation_code:** Confirmation code sent via text or email
- **username:** User's username

#### Update Profile ####

Update the user's profile
Expand All @@ -161,9 +190,14 @@ u = Cognito('your-user-pool-id','your-client-id',
id_token='id-token',refresh_token='refresh-token',
access_token='access-token')

u.update_profile({'given_name':'Edward','family_name':'Smith',})
u.update_profile({'given_name':'Edward','family_name':'Smith',},attr_map=dict())
```

##### Arguments

- **attrs:** Dictionary of attribute name, values
- **attr_map:** Dictionary map from Cognito attributes to attribute names we would like to show to our users

#### Send Verification ####

Send verification email or text for either the email or phone attributes.
Expand All @@ -178,6 +212,10 @@ u = Cognito('your-user-pool-id','your-client-id',
u.send_verification(attribute='email')
```

##### Arguments

- **attribute:** - The attribute (email or phone) that needs to be verified

#### Get User Object

Returns an instance of the specified user_class.
Expand All @@ -200,21 +238,39 @@ u.get_user_obj(username='bjones',
- **attr_map: (optional)** Dictionary that maps the Cognito attribute names to what we'd like to display to the users


#### Get User ####

Get all of the user's attributes
#### Get User

**Important:** Returns a UserObj project
Get all of the user's attributes. Gets the user's attributes using Boto3 and uses that info to create an instance of the user_class

```python
from warrant import Cognito

u = Cognito('your-user-pool-id','your-client-id',
username='bob')

user = u.get_user()
user = u.get_user(attr_map={"given_name":"first_name","family_name":"last_name"})
```

##### Arguments
- **attr_map:** Dictionary map from Cognito attributes to attribute names we would like to show to our users

#### Get Users

Get a list of the user in the user pool.


```python
from warrant import Cognito

u = Cognito('your-user-pool-id','your-client-id')

user = u.get_users(attr_map={"given_name":"first_name","family_name":"last_name"})
```

##### Arguments
- **attr_map:** Dictionary map from Cognito attributes to attribute names we would like to show to our users


#### Check Token

Checks the exp attribute of the access_token and either refreshes the tokens by calling the renew_access_tokens method or does nothing. **IMPORTANT:** Access token is required
Expand All @@ -232,7 +288,7 @@ No arguments for check_token

#### Logout ####

Logs the user out of all clients. Erases the access token.
Logs the user out of all clients and removes the expires_in, expires_datetime, id_token, refresh_token, access_token, and token_type attributes.

```python
from warrant import Cognito
Expand All @@ -245,6 +301,9 @@ u = Cognito('your-user-pool-id','your-client-id',

u.logout()
```
##### Arguments

No arguments for check_token

## Cognito SRP Utility
The `AWSSRP` class is used to perform [SRP(Secure Remote Password protocol)](https://www.ietf.org/rfc/rfc2945.txt) authentication.
Expand Down
4 changes: 3 additions & 1 deletion warrant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def logout(self):
def update_profile(self, attrs,attr_map=dict()):
"""
Updates User attributes
:parm attrs: Dictionary of attribute name, values
:param attrs: Dictionary of attribute name, values
:param attr_map: Dictionary map from Cognito attributes to attribute
names we would like to show to our users
"""
user_attrs = dict_to_cognito(attrs,attr_map)
response = self.client.update_user_attributes(
Expand Down

0 comments on commit d2b5371

Please sign in to comment.