Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add attachment using oauth accessToken (not userName & password) ?

Xing Guo
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 31, 2018

How to add attachment using oauth accessToken (not userName & password) ?

Codes below can only do normal post to Jira (create issue or add comment):

OAuthAccessor accessor = getAccessor();
OAuthClient client = new OAuthClient(new HttpClient4());
accessor.accessToken = accessToken;
OAuthMessage request = accessor.newRequestMessage(method, url, Collections.<Map.Entry<?, ?>>emptySet(), bodyAsStream);
List<Map.Entry<String, String>> headers = request.getHeaders();
headers.add(new OAuth.Parameter(HttpMessage.CONTENT_TYPE, "application/json"));
headers.add(new OAuth.Parameter(HttpMessage.CONTENT_LENGTH, contentLength));
headers.add(new OAuth.Parameter(HttpMessage.DEFAULT_CHARSET, "UTF-8"));

OAuthMessage response = client.invoke(request, ParameterStyle.AUTHORIZATION_HEADER);

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira product discovery learning path, product discovery training, idea prioritization, align stakeholders, discovery to delivery, product collaboration, atlassian learning, dev process, roadmap planning, insight capture, team alignment

Elevate Your Skills with Jira Product Discovery!

Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!

Start Learning
AUG Leaders

Atlassian Community Events