authenticate with cognito backend
Project description
villaAuthSdk
interact with villa authentication backend
Install
pip install villaAuthSdk
How to use
create an auth object
from villaAuthSdk.auth import AuthSdk
from nicHelper.dictUtil import printDict
sdk=AuthSdk(user=None,pw=None,region='ap-southeast-1')
## user and pw here are the aws key/secret for your client
Create cashier
sdk.createCashier({
'user': 'nic1',
'phone': '+66816684442',
'pw': '12345678',
'name': 'nic',
'cashierCode': '001',
'email': 'test@gmail.com'
})
{'success': True,
'user': 'nic1',
'phone': '+66816684442',
'pw': '12345678',
'name': 'nic',
'cashierCode': '001',
'email': 'test@gmail.com',
'body': '{"Username":"nic1","UserAttributes":{"sub":"f5aa60ba-0f65-45f3-b8f7-2a064e7e5311","email_verified":"false","name":"nic","custom:cashierCode":"001","phone_number_verified":"true","phone_number":"+66816684442","email":"test@gmail.com"},"UserCreateDate":1606995525.734,"UserLastModifiedDate":1606995525.988,"Enabled":true,"UserStatus":"CONFIRMED","ResponseMetadata":{"RequestId":"6b2010b5-aabc-4d36-8e3e-0234da56f3ab","HTTPStatusCode":200,"HTTPHeaders":{"date":"Thu, 03 Dec 2020 11:38:46 GMT","content-type":"application\\/x-amz-json-1.1","content-length":"467","connection":"keep-alive","x-amzn-requestid":"6b2010b5-aabc-4d36-8e3e-0234da56f3ab"},"RetryAttempts":0}}',
'statusCode': 200,
'headers': {'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': '*'}}
login
result = sdk.auth(user='nic1',pw='12345678')
printDict(result)
AccessKeyId : ASIAVX4Z5T
SecretKey : zTt7RyFFji
SessionToken : IQoJb3JpZ2
Expiration : 1606999129.0
AccessToken : eyJraWQiOi
ExpiresIn : 3600
TokenType : Bearer
RefreshToken : eyJjdHkiOi
IdToken : eyJraWQiOi
NewDeviceMetadata
DeviceKey : ap-southea
DeviceGroupKey : -lt0cpemm
userInfo
Username : nic1
UserCreateDate : 1606995525.734
UserLastModifiedDate : 1606995525.988
Enabled : True
UserStatus : CONFIRMED
ResponseMetadata
RequestId : 44425d05-8
HTTPStatusCode : 200
HTTPHeaders
date : Thu, 03 De
content-type : applicatio
content-length : 467
connection : keep-alive
x-amzn-requestid : 44425d05-8
RetryAttempts : 0
kwUserAttrib
sub : f5aa60ba-0
email_verified : false
name : nic
custom:cashierCode : 001
phone_number_verified : true
phone_number : +668166844
email : test@gmail
Confirm
confirm phone/email
result=sdk.confirm(user='nic1', code= '123')
printDict(result)
error
pickledb64string : gASVTQUAAA
error : confirmati
Get Profile
result=sdk.getProfile('nic1')
printDict(result)
Username : nic1
UserAttributes
sub : f5aa60ba-0
email_verified : false
name : nic
custom:cashierCode : 001
phone_number_verified : true
phone_number : +668166844
email : test@gmail
UserCreateDate : 1606995525.734
UserLastModifiedDate : 1606995525.988
Enabled : True
UserStatus : CONFIRMED
ResponseMetadata
RequestId : 85a734ac-2
HTTPStatusCode : 200
HTTPHeaders
date : Thu, 03 De
content-type : applicatio
content-length : 467
connection : keep-alive
x-amzn-requestid : 85a734ac-2
RetryAttempts : 0
update Profile
result = sdk.updateProfile(
user= 'nic1',
attributes= {
'custom:cashierCode': '1234'
})
printDict(result)
Username : nic1
UserAttributes
sub : f5aa60ba-0
email_verified : false
name : nic
custom:cashierCode : 1234
phone_number_verified : true
phone_number : +668166844
email : test@gmail
UserCreateDate : 1606995525.734
UserLastModifiedDate : 1606995533.461
Enabled : True
UserStatus : CONFIRMED
ResponseMetadata
RequestId : ec6ffad2-1
HTTPStatusCode : 200
HTTPHeaders
date : Thu, 03 De
content-type : applicatio
content-length : 468
connection : keep-alive
x-amzn-requestid : ec6ffad2-1
RetryAttempts : 0
set password
sdk.setPassword(user='nic1',pw='12345678')
{'ResponseMetadata': {'RequestId': 'e878f2d6-d1de-487c-8a0a-484072b82309',
'HTTPStatusCode': 200,
'HTTPHeaders': {'date': 'Thu, 03 Dec 2020 11:38:54 GMT',
'content-type': 'application/x-amz-json-1.1',
'content-length': '2',
'connection': 'keep-alive',
'x-amzn-requestid': 'e878f2d6-d1de-487c-8a0a-484072b82309'},
'RetryAttempts': 0}}
Unauth
get unauthenticated credentials
result = sdk.unauth()
printDict(result)
AccessKeyId : ASIAVX4Z5T
SecretKey : UbsJ2mlM3z
SessionToken : IQoJb3JpZ2
Expiration : 1606999136.0
DeleteUser
result = sdk.deleteUser(user='nic1')
printDict(result)
ResponseMetadata
RequestId : 7e3fc4ac-5
HTTPStatusCode : 200
HTTPHeaders
date : Thu, 03 De
content-type : applicatio
content-length : 0
connection : keep-alive
x-amzn-requestid : 7e3fc4ac-5
RetryAttempts : 0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
villaAuthSdk-0.0.12.tar.gz
(12.5 kB
view details)
Built Distribution
File details
Details for the file villaAuthSdk-0.0.12.tar.gz
.
File metadata
- Download URL: villaAuthSdk-0.0.12.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a166c83660a618431fc6cb2f492f1671ef5d4b3052fcec1009d80d606a10bd9 |
|
MD5 | b8a8c2fbeaa8f704215a42ed14660aea |
|
BLAKE2b-256 | 70df34cdc2e2ece813138e1300a88bad74292b17ca9fd3719903898974928e8c |
File details
Details for the file villaAuthSdk-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: villaAuthSdk-0.0.12-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df681e8c8985b1e87ca67c9fc87b9d213858f7f435dbc679696c5adcdeebe195 |
|
MD5 | 1762e5afec13990eab4810a0bb80a8b8 |
|
BLAKE2b-256 | a7b4e08dac1fc96acecb535b9e5b915803e5d61994d9e4bb8f1ee9ee60ca2a96 |