如何在HANA XS中使用OAuth 2.0消费salesforce Apex Rest API服务

2020-09-13 13:37发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中) SalesforceAP...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


SalesforceAPI.xshttpdest

 description ="我的HTTP目标";
 主机=" dbsystemsp2000350343trial.hanatrial.ondemand.com";
 端口= 443;
 pathPrefix ="/img/services/apexrest/AccountDetails";
 proxyType = http;
 proxyHost =" salesforcecors.herokuapp.com";
 proxyPort = 4300;
 authType =无;
 useSSL = true;
 超时= 30000;
 oAuthAppConfigPackage =" SalesforceAPI";
 oAuthAppConfig =" SalesforceAPI";
 sslHostCheck = true;
 sslAuth =客户端;
 

SalesforceAPI.xsoauthappconfig

 {
 " clientConfig":" SalesforceAPI:SalesforceAPI",
 " description":" OAuth的Salesforce测试应用程序"
 }
 

SalesforceAPI.xsoauthclientconfig

 {
 " clientFlavor":" SalesforceAPI:SalesforceAPI",
 " clientID":" 3MVG9E4..z.hDcPKzw7ZbEaOhlOjjkbWUV_7.dMV.su.Be_4Cmey0G5cvmOMuQlF6P.nO1FDLzOhx0aNh7014"
 " clientAuthType":"证书",
 " authorizationEndpointURL":"/img/services/oauth2/authorize",
 " tokenEndpointURL":"/img/services/oauth2/token",
 " revocationEndpointURL":"/服务/oauth2/令牌/吊销",
 " flow":" authCode",
 " description":" Salesforce的OAuth客户端",
 " samlIssuer":"",
 " redirectURL":"/img/services/oauth2/callback",
 " scopeReq":" maxScopes",
 " shared":" true",
 " modify":" SalesforceAPI:SalesforceAPI"
 }
 

token.xsjs

 function getData(){
//创建客户端
 var client = new $ .net.http.Client();


//发送地点和内容
 var dest = $ .net.http.readDestination(" SalesforceAPI"," SalesforceAPI");
 var request = new $ .net.http.Request($。net.http.GET,"/img/services/apexrest/AccountDetails"); //新的请求(METHOD,PATH)

//发送请求并同步获取响应
 client.request(请求,目标);
 var response = client.getResponse();

//获取身体
 var body;
 if(!response.body){
 身体="我在这里";
 }其他{
 正文= response.body.asString();
 }
 client.close();

//将响应作为JSON发送
 $ .response.contentType =" application/json";
 $ .response.setBody(JSON.stringify({" status":response.status," body":body})));
 }