Something went wrong :-( Something went wrong while trying to load this site; please try again later.
Debugging tips If this is your site, and you just reloaded it, then the problem might simply be that it hasn't loaded up yet. Try refreshing this page and see if this message disappears.
If you keep getting this message, you should check your site's server and error logs for any messages.
Error code: 502-backend
i got this error the code works fine on my pc when running this part of my code
@app.route('/redirect', methods=['GET'])
def redirecturl():
params = {
'client_id': 2773,
'redirect_uri': 'https://www.az-sheets.com/callback',
'response_type': 'code' # Your Application's Callback URI
}
# requests.post('https://oauth.zid.sa/oauth/token', data=params)
url = (f"https://oauth.zid.sa/oauth/authorize?{urlencode(params)}")
return redirect(url)
@app.route('/callback', methods=['GET'])
def callback():
payload = {
'grant_type': 'authorization_code',
'client_id': 2773,
'client_secret': 'OnW69gzChkb89GNgZ8XMTKmFvtZUYK0Do5EXgBAB',
'redirect_uri': 'https://www.az-sheets.com/callback',
'code': request.args.get('code') # grant code
}
response = requests.post('https://oauth.zid.sa/oauth/token', data=payload)
return redirect(url_for('em', access_token=response.json()['access_token'], Authorization=response.json()['authorization'], refresh_token=response.json()['refresh_token']))
@app.route('/HAMAD', methods=['GET'])
def em():
print(1)
access_token = request.args.get('access_token')
Authorization = request.args.get('Authorization')
refresh_token = request.args.get('refresh_token')
url = 'https://api.zid.sa/v1/managers/account/profile'
headers = {
'Authorization': f'Bearer {Authorization}',
'x-manager-token': f'{access_token}',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
url = 'https://api.zid.sa/v1/managers/embedded-apps-token'
headers = {
'Authorization': f'Bearer {Authorization}',
'x-manager-token': f'{access_token}',
'Content-Type': 'application/json'
}
data = {
'token': str(response.json()['user']['store']['id']).translate(ecode)
}
rs = requests.post(url, headers=headers, json=data)
db_handler.newstore(response.json()['user']['store']['id'],access_token,Authorization,refresh_token)
url = "https://api.zid.sa/v1/managers/webhooks"
payload = {
"event": "order.status.update",
"target_url": "https://www.az-sheets.com/zidwebhooks",
"original_id": 1,
"subscriber": "AZsheets",
}
headers = {
'Authorization': f'Bearer {Authorization}',
'x-manager-token': f'{access_token}',
"Content-Type": "application/json",
"Accept": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
return redirect('https://web.zid.sa/market/embedded/2924')