Sample code for 30+ languages & platforms
Classic ASP Requires Chilkat v11.0.0+

Jira Cloud: Authenticate with an API Token

See more Jira Examples

Verify an API token by retrieving the authenticated user's account ID and display name. Use your Atlassian account email as the Basic authentication username and an API token as the password, not your account password.

API tokens are suitable for scripts and internal integrations. Keep tokens out of source control and logs, track their expiry, and grant only the scopes needed. A scoped token uses the Atlassian gateway URL; a token without scopes uses the site URL. Find the Cloud ID in Atlassian administration or the site's /_edge/tenant_info response. Distributable integrations should use Atlassian's supported OAuth2 app model.

The code uses an Atlassian account email and an API token without scopes with the site URL. For a scoped API token, keep Basic authentication and change baseUrl to https://api.atlassian.com/ex/jira/YOUR_CLOUD_ID. For OAuth2, use that gateway URL, omit Login/Password/BasicAuth, and set http.AuthToken to the access token. See API token authentication and OAuth2 authorization. The account must have permission for the operation; OAuth scopes do not grant additional Jira permissions.

Targets Jira Cloud. Jira Data Center has a separate REST API and may require different paths, authentication, or payloads.

Atlassian REST API documentation

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.

set http = Server.CreateObject("Chilkat.Http")
http.RequireSslCertVerify = 1
http.BasicAuth = 1
'  Read these credentials from private application configuration.
http.Login = "YOUR_ATLASSIAN_EMAIL"
http.Password = "YOUR_API_TOKEN"
baseUrl = "https://your-domain.atlassian.net"
http.Accept = "application/json"
set url = Server.CreateObject("Chilkat.StringBuilder")
set resp = Server.CreateObject("Chilkat.HttpResponse")
set reply = Server.CreateObject("Chilkat.JsonObject")
success = url.SetString(baseUrl)
success = url.Append("/rest/api/3/myself")
success = http.HttpNoBody("GET",url.GetAsString(),resp)
If (resp.StatusCode = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response was received. Check connectivity and TLS settings.") & "</pre>"
    Response.End
End If

If ((success <> 1) Or (resp.StatusCode < 200) Or (resp.StatusCode >= 300)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Request failed. HTTP " & resp.StatusCode) & "</pre>"
    If (resp.StatusCode = 429) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Rate limited. Retry-After: " & resp.GetHeaderField("Retry-After")) & "</pre>"
    End If

    '  Inspect this response locally; it can contain private Jira data.
    Response.Write "<pre>" & Server.HTMLEncode( resp.BodyStr) & "</pre>"
    Response.End
End If

success = reply.Load(resp.BodyStr)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Expected a JSON object in the response.") & "</pre>"
    Response.End
End If

If ((reply.JsonTypeOf("accountId") <> 1) Or (reply.StringOfEquals("accountId","",1) = 1)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Missing value: accountId") & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Account ID: " & reply.StringOf("accountId")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Display name: " & reply.StringOf("displayName")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Active: " & reply.BoolOf("active")) & "</pre>"

%>
</body>
</html>