Skip to content

api.User(username) panics with invalid memory address error #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shansara-ghub opened this issue Jun 22, 2021 · 4 comments
Closed

api.User(username) panics with invalid memory address error #32

shansara-ghub opened this issue Jun 22, 2021 · 4 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@shansara-ghub
Copy link

shansara-ghub commented Jun 22, 2021

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.

@c-seeger
Copy link
Contributor

c-seeger commented Jun 22, 2021

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.

@shansara-ghub
Copy link
Author

shansara-ghub commented Jun 22, 2021

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 ?

@c-seeger
Copy link
Contributor

c-seeger commented Jun 24, 2021

@shansara-ghub no OAuth is not implemented yet. I'll open another issue for this as a feature request.

@c-seeger
Copy link
Contributor

@shansara-ghub can you confirm if the fix works now with basic auth?

@c-seeger c-seeger self-assigned this Jun 26, 2021
@c-seeger c-seeger added bug Something isn't working question Further information is requested labels Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants