[英]Consuming SAP NetWeaver Gateway Services from Android app
I am developing an application in Android which consumes OData services provided by SAP NetWeaver gateway, I am using Odata4J library for consuming services.我正在 Android 中开发一个应用程序,它使用 SAP NetWeaver 网关提供的 OData 服务,我使用 Odata4J 库来使用服务。
ODataConsumer consumer = ODataConsumers
.create("https://sapes1.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/");
when I am hitting this URL from web browser, it prompts "Authentication Required" dialog box where I have to enter my username and password and after that I can see service document, schema document etc.当我从 Web 浏览器点击此 URL 时,它会提示“需要身份验证”对话框,我必须在其中输入用户名和密码,然后才能看到服务文档、架构文档等。
My question is: how can I pass credentials with my request using Odata4J?我的问题是:如何使用 Odata4J 在我的请求中传递凭据? Do I receive any kind of token after successful authentication for authenticating further requests?
身份验证成功后,我是否会收到任何类型的令牌以对进一步的请求进行身份验证?
You can pass credentials with the call.您可以通过调用传递凭据。 OAUTH,SAML2,X509, Basic Auth etc.
OAUTH、SAML2、X509、基本身份验证等。
eg例如
ODataConsumer.newBuilder(serviceUri).setClientBehaviors(OClientBehaviors.basicAuth(user,
password)).build();
//sorry this was the c#
var creds = username + ":" + password;
var encodedCreds = Convert.ToBase64String(Encoding.ASCII.GetBytes(creds));
requestHeaders.Add("Authentication", "Basic" + encodedCreds);
Normally the system (if configured properly) will issue a MYSAPSSO2 cookie.通常系统(如果配置正确)会发出一个 MYSAPSSO2 cookie。 This cookie can be re-sent with subsequent requests.
此 cookie 可以与后续请求一起重新发送。
search for Basic Auth and OdataConsumer, a few examples will show up.搜索 Basic Auth 和 OdataConsumer,将显示一些示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.