<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: How to implement OData based BASIC Authentication using HTML, JavaScript for Mobile Apps using Apache Cordova/PhoneGap and datajs-1.1.1.js library in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159397#M3667342</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the link given by you, but could not make anything out of it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It used the code, but it didnt work for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you kindly explain me about the code from the link shared by you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Suraj Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Mar 2014 08:45:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2014-03-28T08:45:53Z</dc:date>
    <item>
      <title>How to implement OData based BASIC Authentication using HTML, JavaScript for Mobile Apps using Apache Cordova/PhoneGap and datajs-1.1.1.js library</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaq-p/10159393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am currently developing an App using HTML, JavaScript, SAP UI5 framework and Apache Cordova/PhoneGap, with OData NetWeaver Gateway service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing issues with BASIC Authentication. I have written the code to handle both Valid and Invalid credentials. The code for invalid login scenario work in a way on browser, but not in the iOS App created using Apache Cordova/PhoneGap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before going on to the App issue on the mobile device, let me explain how it is executing on the browser, so that you may have a clear picture of the issue I am going through.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While executing or testing the App's code in browser, if I enter invalid login credentials and tap on the &lt;STRONG&gt;Login&lt;/STRONG&gt; button, the OData Service related code is fired and as the credentials are invalid, the browser displays an SAP Login prompt as shown in below Screen shot # 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/419521" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I tap on the &lt;STRONG&gt;Cancel&lt;/STRONG&gt; button, in the login prompt, that is when the login failure related code written by me, to display Login Error message is displayed, as shown in below Screen Shot # 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/419547" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I have to develop an iOS Mobile App, I am using Apache Cordova/PhoneGap and placing my HTML , JavaScript code into the PhoneGap project and building the app.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I test my App by entering invalid credentials and tap on the &lt;STRONG&gt;Login&lt;/STRONG&gt; button, nothing happens. The App appears to be in a sort of &lt;STRONG&gt;stand-still.&lt;/STRONG&gt; Logically the app has to display the login error message, as shown in above Screen shot # 2, but it doesn't do so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Moreover, after waiting for about 30 to 40 seconds and may be even more, when I erase the invalid credentials, enter valid credentials and tap on the &lt;STRONG&gt;Login&lt;/STRONG&gt; button, the app continues with the logic written for valid credentials.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not able to understand why the app behaves this way on the mobile device i.e. the iPad here in this case. Later on, we will be creating an Android version of the same app, using the same code and Cordova/PhoneGap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For OData calls, I have used the standard &lt;STRONG&gt;datajs-1.1.1.js&lt;/STRONG&gt; library and &lt;STRONG&gt;Base64.js&lt;/STRONG&gt; library to encrypt the credentials for security.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be of great help, if you could guide me in resolving the issue or provide any reference, which might at least give a lead towards the solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI :&lt;/P&gt;&lt;P&gt;The overall setup is simple, from the Mobile Device, the App will directly connect to the SAP Backend, over the internet, through OData service written in ABAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Awaiting for your valuable inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Suraj Kumar Midgay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2014 05:59:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaq-p/10159393</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-03-27T05:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement OData based BASIC Authentication using HTML, JavaScript for Mobile Apps using Apache Cordova/PhoneGap and datajs-1.1.1.js library</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159394#M3667339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can ask this question to the experts in this space, &lt;A __default_attr="2421" __jive_macro_name="community" class="jive_macro_community jive_macro" data-orig-content="UI Development Toolkit for HTML5 Developer Center" href="https://community.sap.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2014 06:12:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159394#M3667339</guid>
      <dc:creator>midhun_vp</dc:creator>
      <dc:date>2014-03-27T06:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement OData based BASIC Authentication using HTML, JavaScript for Mobile Apps using Apache Cordova/PhoneGap and datajs-1.1.1.js library</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159395#M3667340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suraj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hybrid mobile apps doesn't support basic authentication popups,that is the reason you're not getting basic auth popup. You should look at your login failure logic, are you waiting for 401 authorisation failed response ? it seems the event your waiting for on login failure is not getting triggered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This post might help you:&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="3382887" __jive_macro_name="thread" class="jive_macro_thread jive_macro" data-orig-content="Auth with SAPUI5 Mobile" href="https://community.sap.com/" modifiedtitle="true" title="Auth with SAPUI5 Mobile"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2014 08:09:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159395#M3667340</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-03-27T08:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement OData based BASIC Authentication using HTML, JavaScript for Mobile Apps using Apache Cordova/PhoneGap and datajs-1.1.1.js library</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159396#M3667341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Midhun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your suggestion. I ahve done so. Hope to find a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;Suraj Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2014 08:43:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159396#M3667341</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-03-28T08:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement OData based BASIC Authentication using HTML, JavaScript for Mobile Apps using Apache Cordova/PhoneGap and datajs-1.1.1.js library</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159397#M3667342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the link given by you, but could not make anything out of it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It used the code, but it didnt work for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you kindly explain me about the code from the link shared by you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Suraj Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2014 08:45:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159397#M3667342</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-03-28T08:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement OData based BASIC Authentication using HTML, JavaScript for Mobile Apps using Apache Cordova/PhoneGap and datajs-1.1.1.js library</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159398#M3667343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suraj,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You can refer this blog, It might help you...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="90077" __jive_macro_name="blogpost" class="jive_macro jive_macro_blogpost" data-orig-content="Authentication with SAP Backend for SAPUI5 Hybrid Phonegap apps" href="https://community.sap.com/" modifiedtitle="true" title="Authentication with SAP Backend for SAPUI5 Hybrid Phonegap apps"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please elaborate as to how are you trying to authenticate the oData service request...may be by posting a code snippet of what you have done..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Prathik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2014 10:28:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159398#M3667343</guid>
      <dc:creator>prathik</dc:creator>
      <dc:date>2014-03-28T10:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement OData based BASIC Authentication using HTML, JavaScript for Mobile Apps using Apache Cordova/PhoneGap and datajs-1.1.1.js library</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159399#M3667344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Prathik,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code which I am using for OData based BASIC Authentication, for my Mobile App is as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var onSuccess = function(data) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; alert("We are Through"); //Just to check that the OData request was sucessful&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; };&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var onError = function(err) {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; switch(err.response.statusCode) {&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; case 403 : {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; window.alert("Error Code - 403, Service unreachable ");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; break;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; case 401 : {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; window.alert("The credentials are incorrect or missing!");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; break;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; };&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;// dataUserName and dataPassword are the two variables, in which I am storing my Username and Password, respectively.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var connectionRequest = {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; requestUri: "ODATA SERVICE URL GOES HERE/",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; headers: { Authorization : 'Basic ' + Base64.encode(dataUsername + ":" + dataPassword) },&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; method: "POST"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; };&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; OData.request( connectionRequest, onSuccess, onError);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2014 10:46:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-implement-odata-based-basic-authentication-using-html-javascript-for/qaa-p/10159399#M3667344</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-03-28T10:46:13Z</dc:date>
    </item>
  </channel>
</rss>

