Page cover

๐Ÿ“…Get User Last-Login Info

In this article, I would be showing you how to extract user last-activity information from the Atlassian Admin API's using go-atlassian

Step 1: Create a new Go project

Create a new directory for your project and navigate to it in your terminal or command prompt. Initialize a new Go module using the following command:

go mod init your-module-name

Step 2: Install the "go-atlassian" library

To use the "go-atlassian" library, you need to install it as a dependency in your project. Run the following command:

go get github.com/ctreminiom/go-atlassian

Step 3: Import the required packages

Create a new Go file, e.g., main.go, and import the necessary packages:

package main

import (
	"fmt"
	"log"

	"github.com/ctreminiom/go-atlassian/admin"
)

Step 4: Set up Cloud Admin client

Initialize the Atlassian Admin client with your API token:

Step 5: Extract the organization ID

It's required to extract the ID of the organization you're using, the organization ID can be extract on the admin URL, as the image below:

Step 6: Extract the organization users

In this step, we're going to extract the organization users and store them into an array variable, please use the following code block to extract them.

Step 7: Extract the last-login date

With the organization users extracted, we need to iterate each user and extract the last-login information, you can use the following code to do that:

Last updated

Was this helpful?