<?xml version="1.0"?>
<rss version="2.0"><channel><title>Guides: Guides</title><link>https://educloud.ist.com/guides/authentication/?d=1</link><description>Guides: Guides</description><language>en</language><item><title>Fetch and use access token</title><link>https://educloud.ist.com/guides/authentication/fetch-and-use-access-token-r2/</link><description><![CDATA[
<p><img src="https://educloud.ist.com/uploads/monthly_2022_01/love-locks-2901687.jpg.2eef023f3efd726e0aa0b85984230ac6.jpg" /></p>
<p>
	<span> </span> 
</p>

<p>
	<span> </span> 
</p>

<p>
	Most API:s require the requests to include an OAuth 2 bearer token also known as an access token.
</p>

<h2>
	Fetch access token
</h2>

<p>
	An access token can be fetch with a HTTP POST request to <code><a href="https://skolid.se/connect/token" rel="external nofollow">https://skolid.se/connect/token</a></code> with the following form values:
</p>

<ul>
	<li>
		grant_type = client_credentials
	</li>
	<li>
		client_id = client id received from IST
	</li>
	<li>
		client_secret = client secret received from IST
	</li>
	<li>
		(OPTIONAL) scope = the scopes/apis that should be included in the access token. Leave empty to include all scopes allowed for the client.
	</li>
</ul>

<p>
	Example CURL:
</p>

<div>
	<pre class="ipsCode prettyprint lang-c prettyprinted"><span class="pln">curl </span><span class="pun">--</span><span class="pln">location </span><span class="pun">--</span><span class="pln">request POST </span><span class="str">'https://skolid.se/connect/token'</span><span class="pln"> \
</span><span class="pun">--</span><span class="pln">form </span><span class="str">'grant_type=client_credentials'</span><span class="pln"> \
</span><span class="pun">--</span><span class="pln">form </span><span class="str">'client_id=&lt;INSERT CLIENT ID&gt;'</span><span class="pln"> \
</span><span class="pun">--</span><span class="pln">form </span><span class="str">'client_secret=&lt;INSERT CLIENT SECRET&gt;'</span></pre>

	<p>
		 
	</p>
</div>

<p>
	Example Response:
</p>

<div>
	<pre class="ipsCode prettyprint lang-c prettyprinted"><span class="pun">{</span><span class="pln">
    </span><span class="str">"access_token"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"ACCESS_TOKEN"</span><span class="pun">,</span><span class="pln">
    </span><span class="str">"expires_in"</span><span class="pun">:</span><span class="pln"> </span><span class="lit">3600</span><span class="pun">,</span><span class="pln">
    </span><span class="str">"token_type"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"Bearer"</span><span class="pun">,</span><span class="pln">
    </span><span class="str">"scope"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"skolid.profile"</span><span class="pln">
</span><span class="pun">}</span></pre>
</div>

<p>
	<em><code>Basic Auth</code> can also be used for sending the client id and the client secret in the token request.</em>
</p>

<p>
	<strong>NOTE</strong> that the access token is only valid for a limited amount of time, usually an hour.
</p>

<h2>
	Use access token
</h2>

<p>
	An access token is usually included as a bearer token in the requests towards the respective API:s. This is done by using the <code>Authorization</code> HTTP header with the value <code>Bearer &lt;INSERT ACCESS TOKEN&gt;</code>.
</p>

<p>
	Example CURL:
</p>

<div>
	<pre><code>curl --location --request GET 'https://api.ist.com/example' \
--header 'Authorization: Bearer &lt;ACCESS TOKEN&gt;'
</code></pre>
</div>
]]></description><guid isPermaLink="false">2</guid><pubDate>Thu, 30 Dec 2021 12:52:20 +0000</pubDate></item></channel></rss>
