I'm trying to create a Jira issue from a Scriptrunner script, but on create I'm given this error message:
Anonymous users do not have permission to create issues in this project. Please try logging in first.
I have credentials I can use to authenticate, but I don't know how to set them. I've tried the following calls, but they are not working (some appear to only check if you *know* the credentials, not to actually authenticate.
LoginService.authenticate(ApplicationUser, "password")
AuthenticationContext.setLoggedInUser(ApplicationUser)
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(ApplicationUser)
Any ideas how to authenticate?
Hi @mnd ,
would you please paste your code here? I will try to fix it for you. It is hard to tell, where the problem is, there could be different approaches.
When exactly do you try to create the issue? Is it during some transition (i .e. do you use special scripted postfunction)?
Thank you.
@Hana Kučerová thank you for the response! I was trying to prepare the simplest version of the code to show you, and it seems like I might have stumbled across a pattern that worked. In my new code I'm using the following block, and I believe it works.
ApplicationUser user = ComponentAccessor.getUserManager().getUserByName("<<user name>>")
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(user)
Unfortunately I'm now getting a StackOverflowError in my code when it is creating the issue, which I imagine is unrelated, but I'm not fully sure. Here's the other question I asked related to that (in the odd event that they are at all related)
Thanks again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.