生成SAP Leonardo API Access Token的python代码
发布日期:2021-06-30 14:18:26 浏览次数:4 分类:技术文章

本文共 1136 字,大约阅读时间需要 3 分钟。

!/usr/bin/env python

-- coding: utf-8 --

import osimport sysimport requestsdef 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代码参考链接:https://help.sap.com/viewer/ed8bf217360e4ad7bcbec7707c017a82/1906B/en-US/066e68162d7249bcb4a8b615cdd7e2a3.html

在这里插入图片描述

转载地址:https://jerry.blog.csdn.net/article/details/105457162 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:如何判断一个SAP CRM UI能否被扩展
下一篇:SAP CRM business partner Address and person name format

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月22日 02时18分02秒