Skip to content

Commit

Permalink
Added parameter client_secret (#17)
Browse files Browse the repository at this point in the history
* Added parameter client_secret

* Added client_secret argument

* Some code formatting

* Added client_secret argument to example.

* Update yoomoney/authorize/authorize.py

---------

Co-authored-by: Aleksey Korshuk <48794610+AlekseyKorshuk@users.noreply.github.com>
  • Loading branch information
SevaShpun and AlekseyKorshuk authored Jul 4, 2024
1 parent 2782b56 commit 531ca74
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ First of all we need to receive an access token.
2. Go to the `App registration <https://yoomoney.ru/myservices/new>`_ page.
3. Set the application parameters. Save CLIENT_ID and YOUR_REDIRECT_URI for net steps
4. Click the Confirm button.
5. Paste CLIENT_ID and REDIRECT_URI insted of YOUR_CLIENT_ID and YOUR_REDIRECT_URI. Choose scopes and run code.
5. Paste CLIENT_ID, REDIRECT_URI and CLIENT_SECRET insted of YOUR_CLIENT_ID, YOUR_REDIRECT_URI and YOUR_CLIENT_SECRET. Choose scopes and run code.
6. Follow all steps from the program.

.. code:: python
Expand All @@ -87,6 +87,7 @@ First of all we need to receive an access token.
Authorize(
client_id="YOUR_CLIENT_ID",
redirect_uri="YOUR_REDIRECT_URI",
client_secret="YOUR_CLIENT_SECRET",
scope=["account-info",
"operation-history",
"operation-details",
Expand Down
15 changes: 8 additions & 7 deletions examples/authorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
Authorize(
client_id="YOUR_CLIENT_ID",
redirect_uri="YOUR_REDIRECT_URI",
client_secret="YOUR_CLIENT_SECRET",
scope=["account-info",
"operation-history",
"operation-details",
"incoming-transfers",
"payment-p2p",
"payment-shop",
]
)
"operation-history",
"operation-details",
"incoming-transfers",
"payment-p2p",
"payment-shop",
]
)
1 change: 0 additions & 1 deletion examples/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@
print("\tAmount -->", operation.amount)
print("\tLabel -->", operation.label)
print("\tType -->", operation.type)

2 changes: 1 addition & 1 deletion examples/operation_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
max_size = len(max(properties, key=len))

for prop in properties:
print(prop, " " * (max_size - len(prop)), "-->", str(details.__getattribute__(prop)).replace('\n', ' '))
print(prop, " " * (max_size - len(prop)), "-->", str(details.__getattribute__(prop)).replace('\n', ' '))
14 changes: 7 additions & 7 deletions examples/quickpay.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from yoomoney import Quickpay

quickpay = Quickpay(
receiver="410019014512803",
quickpay_form="shop",
targets="Sponsor this project",
paymentType="SB",
sum=150,
)
receiver="410019014512803",
quickpay_form="shop",
targets="Sponsor this project",
paymentType="SB",
sum=150,
)

print(quickpay.base_url)
print(quickpay.redirected_url)
print(quickpay.redirected_url)
9 changes: 3 additions & 6 deletions yoomoney/authorize/authorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
UnauthorizedClient,
InvalidGrant,
EmptyToken
)
)

class Authorize:
def __init__(
self,
client_id: str,
redirect_uri: str,
client_secret: str,
scope: List[str]
):

Expand All @@ -39,11 +40,7 @@ def __init__(
pass

url = "https://yoomoney.ru/oauth/token?code={code}&client_id={client_id}&" \
"grant_type=authorization_code&redirect_uri={redirect_uri}".format(code=str(code),
client_id=client_id,
redirect_uri=redirect_uri,
)

"grant_type=authorization_code&redirect_uri={redirect_uri}&client_secret={client_secret}".format(code=str(code), client_id=client_id, redirect_uri=redirect_uri, client_secret=client_secret )
response = requests.request("POST", url, headers=headers)

if "error" in response.json():
Expand Down

0 comments on commit 531ca74

Please # to comment.