生成SAP Leonardo API Access Token的python代码
发布日期:2021-06-30 14:18:26
浏览次数:3
分类:技术文章
本文共 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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
表示我来过!
[***.240.166.169]2024年05月06日 01时21分14秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
fmt在bss段(neepusec_easy_format)
2021-07-03
tensorflow 数据格式
2021-07-03
tf keras SimpleRNN源码解析
2021-07-03
MyBatisPlus简单入门(SpringBoot)
2021-07-03
攻防世界web进阶区web2详解
2021-07-03
xss-labs详解(上)1-10
2021-07-03
xss-labs详解(下)11-20
2021-07-03
攻防世界web进阶区ics-05详解
2021-07-03
攻防世界web进阶区ics-04详解
2019-04-30
sql注入总结学习
2019-04-30
Python 之 histogram直方图
2019-04-30
Python实现决策树 Desision Tree & 可视化
2019-04-30
决策树 Decision tree
2019-04-30
nominal和ordinal & 数据处理中四种基本数据类型
2019-04-30
Trie树(字典树)
2019-04-30
COMP7404 Machine Learing——ROC
2019-04-30
MATLAB与CUDA
2019-04-30
Linux png转jpg (convert命令)
2019-04-30
Ubuntu更新后终端中字体的颜色全是白色
2019-04-30