Skip to content

Commit

Permalink
Merge pull request #3 from tbgracy/master
Browse files Browse the repository at this point in the history
[IMP] Consummer key & secret key as env variables.
  • Loading branch information
rivo2302 authored Sep 1, 2022
2 parents 23aacbc + 1569d63 commit 6548822
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONSUMER_KEY=GAQRHpf9DvxqdrkFFfeFwyqQvf4a
SECRET_KEY=7p4pM2f29cQb2CZjeoMheCH8rqka
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ celerybeat.pid
*.sage.py

# Environments
.env
# .env
.venv
env/
venv/
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@ After you create application , you should have Consummer_key and Consummer_secre
# Import the module mvola
from mvola import Mvola

# Import environ module to access environment variables
from os import environ

# Import and load the dotenv module to get environment variables from a .env file in order to avoid altering system environment variables
from dotenv import load_dotenv
load_dotenv()

# Initiate the api => API(Consummer_key, Consummer_secret)
api = Mvola("{{consummer_key}}","{{consummenr_secret}}")
api = Mvola(environ['CONSUMER_KEY'], environ['SECRET_KEY'])
```

### Generate token
Expand Down
7 changes: 6 additions & 1 deletion demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
from datetime import datetime
import threading
from time import sleep
from dotenv import load_dotenv
from os import environ

load_dotenv()

api = Mvola("0zL7eTrSEfXf6kkwJ53DSegCbBwa", "pd8PIZYmeZaafifZgwHu1BC5ucMa")
api = Mvola(environ['CONSUMER_KEY'], environ['SECRET_KEY'])

# GENERATE TOKEN
res = api.generate_token()
print(res.status_code)
if res.success:
print(res.response)
api.token = res.response
else:
print(f"Status_code[{res.status_code}] - {res.error}")
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
requests
requests
python-dotenv

0 comments on commit 6548822

Please sign in to comment.