Login User within Plugin (Jira 7)

Is it possible to login a user within a plugin?


i am developing a scheduler-plugin that runs every X minutes and this plugin create or updates issues. but i always get an error if i do not set the permissions (of the projects) to ANY


Errors: {pid=Anonymous users do not have permission to create issues in this project. Please try logging in first.}

1 answer

In order to log-in a user, the user must somehow provide his credentials - this is not possible in a background job such as a job, executed by the plugin scheduler. What you can do is use a "system" user to create the user - some user in JIRA which has been configured by the administrator in a configuration UI of your plugin and can be used when creating issues. You don't actually need the user password for your job to create issues on behalf of this user - you only need the ApplicationUser instance retrieved using the UserManager service.

I am doing exactly what you described but getting the same error. It seems even if i set the user explicitly on the issueinputparameters, the issue creation service simply ignores it. Do you have an idea what's causing this?

Please share your code so I can take a look.

This is it:

ApplicationUser user = userManager.getUserByName("admin");
            IssueInputParameters params = issueService.newIssueInputParameters().setProjectId(10000L).setIssueTypeId("issuetypeId")
                    .setSummary("summary").setAssigneeId("assigneuser").setDescription("Please enter description");
            CreateValidationResult result = issueService.validateCreate(user, params);
                IssueResult createResult = issueService.create(user, result);
                if (!createResult.isValid())
                    Issue createdIssue = createResult.getIssue();

I tried even injecting login service and logging in as admin before the above code:

LoginResult res = loginService.authenticate(user, "1234");


Thank you!

When you execute the above code (which seems correct) do you see the same error as in the original post? Are you sure there is an active user with the name admin?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


280 views 0 7
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you