<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>REST API &#8211; privacyID3A</title>
	<atom:link href="https://www.privacyidea.org/tag/rest-api/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.privacyidea.org</link>
	<description>flexible, Open Source Multi Factor Authentication (2FA)</description>
	<lastBuildDate>Tue, 01 Nov 2016 07:43:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.privacyidea.org/wp-content/uploads/2016/06/cropped-only-logo-white-background-32x32.png</url>
	<title>REST API &#8211; privacyID3A</title>
	<link>https://www.privacyidea.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Create your own user portal</title>
		<link>https://www.privacyidea.org/create-user-portal/</link>
					<comments>https://www.privacyidea.org/create-user-portal/#respond</comments>
		
		<dc:creator><![CDATA[Cornelius Kölbel]]></dc:creator>
		<pubDate>Tue, 01 Nov 2016 07:43:33 +0000</pubDate>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Google Authenticator]]></category>
		<category><![CDATA[REST API]]></category>
		<guid isPermaLink="false">https://www.privacyidea.org/?p=1089</guid>

					<description><![CDATA[Sometimes it is important to add user self service functionalities to your own portal or create a stripped down version of the privacyIDEA user selfservice. You can strip down the rights for users in a very detailed manner using policies. You can also define an enrollment wizard policy, so that enrolling tokens gets even more [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Sometimes it is important to add user self service functionalities to your own portal or create a stripped down version of the privacyIDEA user selfservice. You can strip down the rights for users in a very detailed manner <a href="http://privacyidea.readthedocs.io/en/latest/policies/user.html" target="_blank">using policies</a>. You can also <a href="https://www.youtube.com/watch?v=diAGbsiG8_A" target="_blank">define an enrollment wizard policy</a>, so that enrolling tokens gets even more simpler. But sometimes even this is not enough.<a href="https://www.privacyidea.org/wp-content/uploads/2016/11/rest-api.png"><img decoding="async" class=" wp-image-1090 alignright" src="https://www.privacyidea.org/wp-content/uploads/2016/11/rest-api-300x256.png" alt="rest-api" width="177" height="151" srcset="https://www.privacyidea.org/wp-content/uploads/2016/11/rest-api-300x256.png 300w, https://www.privacyidea.org/wp-content/uploads/2016/11/rest-api.png 649w" sizes="(max-width: 177px) 100vw, 177px" /></a></p>
<h2>privacyIDEA REST API</h2>
<p>privacyIDEA provides a great and <a href="http://privacyidea.readthedocs.io/en/latest/modules/api.html" target="_blank">simple REST API</a> which lets you automate and integrate all tasks into other workflows. In fact the privacyIDEA Web UI as a single page application uses this REST API. Thus you could easily open the developer tools of your browser and monitor the HTTP requests that are sent.</p>
<h3>Authenticating a user</h3>
<p>A user needs to authenticate at the Web UI and also at the REST API. This is done by issuing the request</p>
<figure id="attachment_1092" aria-describedby="caption-attachment-1092" style="width: 152px" class="wp-caption alignright"><a href="https://www.privacyidea.org/wp-content/uploads/2016/11/auth-request.png"><img decoding="async" class=" wp-image-1092" src="https://www.privacyidea.org/wp-content/uploads/2016/11/auth-request-300x215.png" alt="Auth-Request in the Chrome developer tools." width="152" height="109" srcset="https://www.privacyidea.org/wp-content/uploads/2016/11/auth-request-300x215.png 300w, https://www.privacyidea.org/wp-content/uploads/2016/11/auth-request.png 593w" sizes="(max-width: 152px) 100vw, 152px" /></a><figcaption id="caption-attachment-1092" class="wp-caption-text">Auth-Request in the Chrome developer tools.</figcaption></figure>
<pre>POST /auth</pre>
<p><a href="http://privacyidea.readthedocs.io/en/latest/modules/api/auth.html#post--auth" target="_blank">The auth request</a> takes the username and the users password. Which password the user needs to provide, depends on the <em>login_mode</em> policy in the <em>WebUI</em> scope. The auth request returns an <em>authorization token</em> which needs to be added to each subsequent request.</p>
<p>You can also issue a test request using <em>httpie</em> from the command line like this:</p>
<pre>% http --verify no --pretty all --json POST https://localhost/auth username=secureuser password=test
/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:794: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
 InsecureRequestWarning)
HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 843
Content-Type: application/json
Date: Tue, 01 Nov 2016 07:28:55 GMT
Server: nginx/1.10.0 (Ubuntu)

{
 "id": 1, 
 "jsonrpc": "2.0", 
 "result": {
 "status": true, 
 "value": {
 "default_tokentype": "totp", 
 "log_level": 30, 
 "logout_time": 120, 
 "menus": [], 
 "policy_template_url": "https://raw.githubusercontent.com/privacyidea/policy-templates/master/templates/", 
 "realm": "secure", 
 "rights": [], 
 "role": "user", 
 "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InNlY3VyZXVzZXIiLCJub25jZSI6IjQyYjhhMWIzNDEzYTA5ZmQzMDljMDI3NzY3Mjc4N2I5MmFiNWI2ZWUiLCJhdXRodHlwZSI6InBhc3N3b3JkIiwicmVhbG0iOiJzZWN1cmUiLCJyaWdodHMiOltdLCJyb2xlIjoidXNlciIsImV4cCI6MTQ3Nzk4ODkzNX0.vCXNNV4Bmt2UuC0FMuc2qMbr8i_8zweROadvfLYcJzU", 
 "token_page_size": 15, 
 "token_wizard": false, 
 "token_wizard_2nd": false, 
 "user_details": false, 
 "user_page_size": 15, 
 "username": "secureuser"
 }
 }, 
 "time": 1477985335.376939, 
 "version": "privacyIDEA 2.16.dev3", 
 "versionnumber": "2.16.dev3"
}</pre>
<p>Using the authorization token</p>
<p>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InNlY3VyZXVzZXIiLCJub25jZSI6IjQyYjhhMWIzNDEzYTA5ZmQzMDljMDI3NzY3Mjc4N2I5MmFiNWI2ZWUiLCJhdXRodHlwZSI6InBhc3N3b3JkIiwicmVhbG0iOiJzZWN1cmUiLCJyaWdodHMiOltdLCJyb2xlIjoidXNlciIsImV4cCI6MTQ3Nzk4ODkzNX0.vCXNNV4Bmt2UuC0FMuc2qMbr8i_8zweROadvfLYcJzU</p>
<p>for subsequent call.</p>
<h3>Enrolling a token</h3>
<p>Now the user can enroll a token using the <a href="http://privacyidea.readthedocs.io/en/latest/modules/api/token.html" target="_blank">token endpoints</a>. You need to issue a /token/init request.</p>
<p>To enroll an TOTP token the user would have to issue such a request:</p>
<pre>http --verify no --pretty all --json POST https://localhost/token/init \
     PI-Authorization:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InNlY3VyZXVzZXIiLCJub25jZSI6IjQyYjhhMWIzNDEzYTA5ZmQzMDljMDI3NzY3Mjc4N2I5MmFiNWI2ZWUiLCJhdXRodHlwZSI6InBhc3N3b3JkIiwicmVhbG0iOiJzZWN1cmUiLCJyaWdodHMiOltdLCJyb2xlIjoidXNlciIsImV4cCI6MTQ3Nzk4ODkzNX0.vCXNNV4Bmt2UuC0FMuc2qMbr8i_8zweROadvfLYcJzU \
     type=totp genkey=1 otplen=6</pre>
<p>The secret and also the image of the QR code to be scanned with a smartphone app is contained in the response:</p>
<pre> "googleurl": {
 "description": "URL for google Authenticator", 
 "img": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeoAAAHqAQAAAADjFjCXAAAD90lEQVR4nO2dTY6jSBBGXwxItQSpD+Cj4JuN6khzAziKbwBLS6CYRWaQ6epZGUaW218sEJR5SqUUiv+kzDkg019HaBAuXLhw4cKFCxd+Lm5ZWuzKZkw9MKVHsOtS7uLV63mrC/80HHd3Z3B397lx9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CKa4Tfh4eZ1/zecQ8bjdDjKU0iuuEH5Eftq7MDVcTxOkzieWT2MphhR+Tug9bHfFv6t7sGKNN0TnTpJPwQxL1OmAvC5ejiOzzdWHhVnRGTPhB3PTf64QLFy5cuHDhwv8I/F/uK4F3xSCgRwAAAABJRU5ErkJggg==", 
 "value": "otpauth://totp/TOTP0008C54E?secret=ND2QFT6LIMFXCEARWIMTBT456NY6K7H5&amp;counter=1&amp;digits=6&amp;issuer=privacyIDEA"
 },</pre>
<p>In the same way you could let the user manage his tokens, delete them, reset PINs etc&#8230;</p>
<p>For more information see the <a href="http://privacyidea.readthedocs.io/en/latest/modules/api.html" target="_blank">complete REST API documentation</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.privacyidea.org/create-user-portal/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
