confluence-go-api
confluence-go-api copied to clipboard
api.User(username) panics with invalid memory address error
The api.User() panics with the invalid memory address error. It looks like the cause of the error stems from the getUserEndpoint() as it returns the path as "/rest/api/user/" where as it should return the path as "/rest/api/user?" ?
Because according to the https://developer.atlassian.com/cloud/confluence/rest/api-group-users/#api-api-user-get, see the '?' in the url
curl --request GET \
--url 'https://your-domain.atlassian.net/wiki/rest/api/user?accountId={accountId}' \
--header 'Accept: application/json'
the below works perfectly ok. curl -v -k -X GET 'https://confluence.go.com/rest/api/user?username={gouser}' -H "Authorization: OAuth gousertoken"
{ "type": "known", "username": "GoUser", "userKey": "40282be65460e1310154be02974f2376", "profilePicture": { "path": "/images/icons/profilepics/default.svg", "width": 48, "height": 48, "isDefault": true }, "displayName": "Go Confluence User", "_links": { "base": "https://confluence.go.com", "context": "", "self": "https://confluence.go.com/rest/api/user?key=40282be65460e1310154be02974f2376" } }
Expected behavior The api.User() should ok.
Release version 1.3.2
Additional context The code that produces the error is below for your reference - main.go.txt
Any help is appreciated.
hi @shansara-ghub thanks for your issue. I changed this in branch issue-32. Can you test if the fix works for you?
Btw your main.go example references a fork not the original repo.
Hi @c-seeger - I see when the username and the token are not blank, the authentication being performed is "Basic"
func (r *Request) SetBasicAuth(username, password string) { r.Header.Set("Authorization", "Basic "+basicAuth(username, password)) } func (a *API) Auth(req *http.Request) { //Supports unauthenticated access to confluence: //if username and token are not set, do not add authorization header if a.username != "" && a.token != "" { req.SetBasicAuth(a.username, a.token) } } So the token based auth (OAuth) is not supported ?
@shansara-ghub no OAuth is not implemented yet. I'll open another issue for this as a feature request.
@shansara-ghub can you confirm if the fix works now with basic auth?