栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

通过Python调用SuccessFactors API

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

通过Python调用SuccessFactors API

通过Python实现对SuccessFactors API的调用

import requests
pr1 = {'company_id': 'xxXX',  'client_id': 'XXXX', 'token_url': 'https://api15.sapsf.cn/oauth/token', 'user_id': 'SFADMIN', 'private_key': 'XXXX'}
hd1 = {'Content-Type':"application/x-www-form-urlencoded"}
response = requests.post("https://api15.sapsf.cn/oauth/idp",params=pr1, headers=hd1)
as1 = response.content
# get assertion

# get token
pr2 = {'company_id': 'XXXX', 'client_id': 'XXXX', 'grant_type': 'urn:ietf:params:oauth:grant-type:saml2-bearer', 'user_id': 'SFADMIN', 'assertion': as1}
hd2= {'Content-Type':"application/x-www-form-urlencoded"}
response = requests.post("https://api15.sapsf.cn/oauth/token",params=pr2, headers=hd2)
# get token

# get api entity
attt3 = response.json()['access_token']
kv3= {'Authorization':"Bearer " +attt3}
response = requests.get("https://api15.sapsf.cn/odata/v2/PerEmail", headers=kv3)

# get api entity-reuse session cookie

tk1= response.headers['X-CSRF-Token']
co1= response.headers['Set-Cookie'].split(";")
co2= co1[0]

# get api entity

hd3= {'Cookie': co2, 'X-CSRF-Token':tk1}
response = requests.get("https://api15.sapsf.cn/odata/v2/PerPhone", headers=hd3)


  # 获取SF手机号信息

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/853768.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号