!/usr/bin/env python
-- coding: utf-8 --
import os
import sys
import requests
def get_request_header(xsuaa_base_url, client_id, client_secret):
response = requests.post(url=xsuaa_base_url + '/oauth/token',
data={'grant_type': 'client_credentials',
'client_id': client_id,
'client_secret': client_secret})
access_token = response.json()["access_token"];
with open("C:\\Python27\\911.txt", "w") as f:
f.write(access_token)
f.close()
print(access_token);
return {'Authorization': 'Bearer {}'.format(access_token), 'Accept': 'application/json'}
xsuaa_base_url = 'https://jerry.authentication.sap.hana.ondemand.com';
client_id = 'sb-15537af7-4eae-4a5b-b47d-3e6299010b87!b7033|ml-foundation-xsuaa-std!b313';
client_secret = 'jBwKqk5OdUHQKeCgk5EyHoyBJkk=';
print(get_request_header(xsuaa_base_url, client_id, client_secret));
需要修改client_id,secret, token是有时间限制的,需要每次重新生成,
每次生成都写入一个txt里方便使用,
python代码参考链接:help.sap.com/viewer/ed8b…