-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreauthorize_webhook.py
More file actions
28 lines (22 loc) · 890 Bytes
/
reauthorize_webhook.py
File metadata and controls
28 lines (22 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests
from get_token import _getToken
from webhook_create import api_url
token = _getToken()
def reauthorize_webhook(subscription_id):
"""
Reauthorizes the webhook subscription if it needs to be reauthorized.
Args:
- subscription_id (str): The ID of the webhook subscription.
Returns:
- bool: True if reauthorization is successful, False otherwise.
"""
headers = {
"Authorization": "Bearer " + token,
"Content-Type": "application/json",
}
subscription_url = f"{api_url}/subscriptions/{subscription_id}/reauthorize"
response = requests.post(subscription_url, headers=headers)
if response.status_code:
return True # Reauthorization successful
else:
return False # Reauthorization failed