<!DOCTYPE html>
<html>
<body>
<div class="loggedOut">
<p>
Looks like you're not logged in.
</p>
<p>
Make sure you log into
<a href="https://jira.atlassian.com" target="_blank">https://jira.atlassian.com</a> first
then come back and refresh the page.
</p>
</div>
<div class="loggedIn" style="display:none">
<p>
Hello <b><span class="displayName"></span></b>!
</p>
<p>
Looks like you belong to the following groups: <span class="groups"></span>
</p>
<hr/>
<b>GET /rest/auth/1/session</b>
<pre class="sessionOut"></pre>
<br/>
<b>GET /rest/api/2/user?username=<span class="username"></span>&expand=groups</b>
<pre class="userOut"></pre>
</div>
<script src="https://jira.atlassian.com/rest/auth/1/session?jsonp-callback=authCallback" type="text/javascript"></script>
</body>
</html>
JavaScript
// Called after /session is called getting the username
function authCallback(d) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://jira.atlassian.com/rest/api/2/user?username=' + d.name + '&expand=groups&jsonp-callback=groupsCallback';
head.appendChild(script);
$('.sessionOut').html(JSON.stringify(d, null, 2));
$('.loggedOut').hide();
$('.loggedIn').show();
}
// Called after /user?username= is called getting the user's displayName and groups
function groupsCallback(d) {
var names = $.map(d.groups.items, function(i, e) {
return i.name;
});
$('.username').html(d.name);
$('.displayName').html(d.displayName);
$('.groups').html(names.join(', '));
$('.userOut').html(JSON.stringify(d, null, 2));
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.