βš–
Myself
This resource represents information about the current user, such as basic details, group membership, application roles, preferences, and locale. Use it to get, create, update, and delete.

Get Current User

Returns details for the current user.
1
package main
2
​
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
​
10
func main() {
11
​
12
var (
13
host = os.Getenv("HOST")
14
mail = os.Getenv("MAIL")
15
token = os.Getenv("TOKEN")
16
)
17
​
18
atlassian, err := v2.New(nil, host)
19
if err != nil {
20
return
21
}
22
​
23
atlassian.Auth.SetBasicAuth(mail, token)
24
​
25
currentUser, response, err := atlassian.MySelf.Details(context.Background(), nil)
26
if err != nil {
27
log.Fatal(err)
28
}
29
​
30
log.Println("HTTP Endpoint Used", response.Endpoint)
31
log.Println(currentUser.DisplayName, currentUser.Active, currentUser.AccountID)
32
}
Copied!
​
Export as PDF
Copy link