Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Unable to use API token in python script Edited

Hello all,

I need to disable 900 Atlassian cloud users, I followed https://developer.atlassian.com/cloud/admin/user-management/rest/#api-users-account-id-manage-lifecycle-disable-post

I generated the API token for myself and using in a python script to test it, but I am getting error "{"code":401,"message":"Unauthorized"}". I have site admin access as well as directory admin access. I am able to disable the users via Atlassian portal. My token is also showing as valid in portal.

My code:

import requests
import json

url = "https://api.atlassian.com/users/FirstName.LastName@MyCompany.com/manage/lifecycle/disable"

headers = {
"Content-Type": "application/json",
"Authorization": "Bearer MyApiToken"
}

payload = json.dumps( {
"message": "Disabling Users who have left Company"
} )

response = requests.request(
"POST",
url,
data=payload,
headers=headers
)

print(response.text)

2 answers

1 vote
Dave Meyer Atlassian Team Feb 05, 2020

Hi @Balaji Shinde , did you follow the instructions here to generate your API token? https://confluence.atlassian.com/cloud/create-an-admin-api-key-969537932.html

It's important to understand that the organization API key is not the same as a personal API key.

0 votes
edwin Community Leader Feb 05, 2020

Hi @Balaji Shinde ,

This is the API you're looking for api-group-Users , although there isn't a way of deactivating users in cloud at the moment.

Authenticating to this you'll use your username and api token as the password.

Dave Meyer Atlassian Team Feb 05, 2020

Hi @edwin I think @Balaji Shinde has the correct API, this is indeed a new API that we provide to organization administrators for deactivating accounts across all Atlassian products. Deactivating accounts for users that have left the company is the type of scenario it's designed for.

Like edwin likes this
edwin Community Leader Feb 05, 2020

Gotcha, thanks for the clarification @Dave Meyer !

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Atlassian Access

What's new in Atlassian Access - Webinar

Based on your valuable feedback, we have released several new features to help you gain administrative flexibility with authentication policies, visibility into shadow IT with automatic product disco...

72 views 2 3
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you