dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16584
[Branch ~dhis2-documenters/dhis2/dhis2-docbook-docs] Rev 481: More on web api use
------------------------------------------------------------
revno: 481
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2-docbook-docs
timestamp: Wed 2012-03-21 16:28:17 +0100
message:
More on web api use
modified:
src/docbkx/en/dhis2_user_man_web_api.xml
--
lp:~dhis2-documenters/dhis2/dhis2-docbook-docs
https://code.launchpad.net/~dhis2-documenters/dhis2/dhis2-docbook-docs
Your team DHIS 2 developers is subscribed to branch lp:~dhis2-documenters/dhis2/dhis2-docbook-docs.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-documenters/dhis2/dhis2-docbook-docs/+edit-subscription
=== modified file 'src/docbkx/en/dhis2_user_man_web_api.xml'
--- src/docbkx/en/dhis2_user_man_web_api.xml 2012-03-21 15:04:43 +0000
+++ src/docbkx/en/dhis2_user_man_web_api.xml 2012-03-21 15:28:17 +0000
@@ -93,14 +93,36 @@
<screen><a href="http://apps.dhis2.org/demo/api/reportTables/xIWpSo5jjT1/data.pdf?ou=O6uvpzGd5pu">Maternal Health Bo District 2012</a></screen>
<para>There are many ways to authenticate over the Web and each method has its advantages and disadvantages. For this example we will use an approach where we emulate a login from the web-based login form. To help us we will use the <emphasis role="italic">jQuery</emphasis> javascript library. This javascript code should be embedded in the <emphasis role="italic">head</emphasis> section of the Web page:</para>
<screen>jQuery(document).ready(function() {
- var base = "http://apps.dhis2.org/demo/";
- $.post( base + "dhis-web-commons-security/login.action", {
+ $.post( "http://apps.dhis2.org/demo/dhis-web-commons-security/login.action", {
j_username: "admin", j_password: "district"
}
);
});</screen>
<para>In this code block we ask jQuery to send a POST request to the standard authentication point with two name-value pairs containing the username and password information. We assume that the user has the necessary authorities to view reports in the DHIS 2 Web API. If authentication was successful the server will send a HTTP cookie in the response with a session identifier. This will make sure that the current user is authorized to view reports for up to 60 minutes.</para>
- <para>Caveat: The username and password will be present in the web page in plain text. Make sure you create a dedicated user in DHIS 2 for this purpose given only the minimum authorities required.</para>
- <para>For a full example visit <ulink url="http://apps.dhis2.org/portal"/> and view the page source in a browser. Note that the example web page is hosted within the same domain (apps.dhis2.org) as the demo DHIS 2 instance. This is done to avoid issues related to the "same origin policy", a concept which prevents scripts hosted on one domain to access resources running on another. While one can circumvent this through techniques such as <emphasis role="italic">CORS</emphasis>, there are none which have wide browser support at the moment. Therefore we recommend hosting web pages and portals on the same domain. Techniques using reverse proxies described in the "installation" chapter can be useful in this regard.</para>
+ <para>Caveat: The username and password will be present in the web page in plain text. Make sure you create a dedicated user in DHIS 2 for this purpose provided only with the minimum authorities required.</para>
+ <para>For a full example visit <ulink url="http://apps.dhis2.org/portal"/> and view the page source in a browser. Note that the example web page is hosted within the same domain (apps.dhis2.org) as the demo DHIS 2 instance. This is done to avoid issues related to the "same origin policy", a concept which prevents scripts hosted on one domain to access resources running on another. While one can circumvent this through techniques such as <emphasis role="italic">CORS</emphasis>, there are none which have wide browser support at the moment. Therefore we recommend hosting web pages and portals on the same domain. Techniques using reverse proxies described in the "installation" chapter can be useful in this regard. Finally we provide some sample URLs pointing to various data resources for your inspiration:</para>
+ <itemizedlist>
+ <listitem>
+ <para><ulink url="http://apps.dhis2.org/demo/api/maps/JlXSUIcLsmd/data"/></para>
+ </listitem>
+ <listitem>
+ <para><ulink url="http://apps.dhis2.org/demo/api/maps/data?in=JIVMtpjVZqJ&ou=O6uvpzGd5pu"/></para>
+ </listitem>
+ <listitem>
+ <para><ulink url="http://apps.dhis2.org/demo/api/reports/Cb2BcgxBUPz/data"/></para>
+ </listitem>
+ <listitem>
+ <para><ulink url="http://apps.dhis2.org/demo/api/charts/nwqNUFG9Vky/data"/></para>
+ </listitem>
+ <listitem>
+ <para><ulink url="http://apps.dhis2.org/demo/api/charts/data?in=JIVMtpjVZqJ&ou=O6uvpzGd5pu"/></para>
+ </listitem>
+ <listitem>
+ <para><ulink url="http://apps.dhis2.org/demo/api/charts/data?in=JIVMtpjVZqJ&ou=O6uvpzGd5pu&periods=true"/></para>
+ </listitem>
+ <listitem>
+ <para><ulink url="http://apps.dhis2.org/demo/api/documents/MfHNQx51HT9/data"/></para>
+ </listitem>
+ </itemizedlist>
</section>
</chapter>