Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Scriptrunner failing to execute confluence query using applink from Jira

Im attempting to connect to Confluence from Jira via applink leveraging the provided adaptivist solution at but it is continually failing with a 'nonce_used' error when the cql call is executed.
I've compared the HTTP headers between Jira and confuence for the ouath calls and it all looks like it matches on both sides and at this point Im completely stuck.  I've also tried both applink config options of 'oauth' and 'oauth with impersonation' with the same failing result.

I really need to get this solutoin working since making rest calls using basic auth or an access token is a non-starter due to then needing to add the auth details in the script.

Can someone please help me to understand what may be going wrong here?

  • Jira Server: 8.5.3
  • Confluence Server: 7.5.2
  • Scriptrunner: 6.23

Code being executed from Scriptrunner console:


static ApplicationLink createPrimaryConfluenceLink() {
def applicationLinkService = ComponentLocator.getComponent(ApplicationLinkService)

final def conflLink = applicationLinkService.getPrimaryApplicationLink(ConfluenceApplicationType.class)

int findConfluencePages() {

def confluenceLink = createPrimaryConfluenceLink()
assert confluenceLink // must have a working app link set up

def authenticatedRequestFactory = confluenceLink.createImpersonatingAuthenticatedRequestFactory()

def responseBody
.createRequest(Request.MethodType.GET, "cql=type%3Dpage%20and%20space%3DAE%20and%20label%3D%22rsp-unreleased%22&expand=body")
.addHeader("Content-Type", "application/json")
.execute(new ResponseHandler<Response>() {
void handle(Response response) throws ResponseException {
if (response.statusCode != HttpURLConnection.HTTP_OK) {
throw new Exception(response.responseBodyAsString)
} else {
responseBody = new JsonSlurper().parseText(response.responseBodyAsString)

responseBody["id"] as Integer


Failing stack:

java.lang.Exception: oauth_problem=nonce_used at Script1167$1.handle(Script1167.groovy:44) at com.atlassian.applinks.oauth.auth.OAuthResponseHandler.handle( at$1.handle( at$1.handle( at$2.handle( at at at at com.atlassian.applinks.core.auth.ApplicationLinkRequestAdaptor.execute( at com.atlassian.applinks.oauth.auth.OAuthResponseHandler.handle( at$1.handle( at$1.handle( at$2.handle( at at at at com.atlassian.applinks.core.auth.ApplicationLinkRequestAdaptor.execute( at com.atlassian.applinks.oauth.auth.OAuthRequest.execute( at$execute$ Source) at Script1167.findConfluencePages(Script1167.groovy:40) at

1 answer

@Greg Bailey 

can you try method may it will help you


def authenticatedRequestFactory = confluenceLink.createAuthenticatedRequestFactory()

def req = authenticatedRequestFactory.createRequest(GET,"cql=type%3Dpage%20and%20space%3DAE%20and%20label%3D%22rsp-unreleased%22&expand=body")

def handler = new ApplicationLinkResponseHandler<Map>() {
Map credentialsRequired(Response response) throws ResponseException {
return null

Map handle(Response response) throws ResponseException {
assert response.statusCode == 200
new JsonSlurper().parseText(response.getResponseBodyAsString()) as Map

def sessionDetails = req.execute(handler)
log.warn("Making the request as: " + sessionDetails)
def json_str = JsonOutput.toJson(sessionDetails)
def jsonSlurper = new JsonSlurper()
def cfg = jsonSlurper.parseText(json_str)
assert cfg instanceof Map
def id = cfg.results['id']

return id

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events