Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Support personal access token #57

Closed
kaakaa opened this issue Aug 9, 2017 · 4 comments
Closed

Support personal access token #57

kaakaa opened this issue Aug 9, 2017 · 4 comments

Comments

@kaakaa
Copy link
Collaborator

kaakaa commented Aug 9, 2017

It seems that Mattermost is going to support personal access token for authenticating REST API from next version.
PLT-6763 Implement user access tokens and new roles (server-side) by jwilander · Pull Request #6972 · mattermost/platform
(user access token renamed personal access token later)

We should support authenticating by personal access token instead of user and password.

@hanzei
Copy link
Member

hanzei commented Aug 14, 2017

So we have to replace login() with another method, haven't we? What is the name of the method? I didn't find one in https://github.com/mattermost/platform/blob/master/model/client4.go

@kaakaa
Copy link
Collaborator Author

kaakaa commented Sep 30, 2017

Sorry for my late reply.

If we use personal access token, we set AuthToken/AuthType directly to model.Client instead of using login() .
https://github.com/mattermost/mattermost-server/blob/master/model/client4.go#L463

The following code works fine for me.

package main

import (
	"log"

	"github.com/mattermost/platform/model"
)

const Token = "dummy_access_token"

func main() {
	c := model.NewAPIv4Client("http://localhost:8065")
	c.AuthToken = Token
	c.AuthType = model.HEADER_BEARER

	u, _ := c.GetMe("")
        log.Printf("%+v", u)
}

@DoktorAerzt
Copy link

I have made a fork to test your solution. At the moment the matterpoll bot is working. I don´t made a Pull Request cause it´s hardcoded to only use the Token and in my version you have no chance to go back to User/Password authentication.

@kaakaa
Copy link
Collaborator Author

kaakaa commented Oct 23, 2018

Matterpoll plugin doesn't need any authentication methods.
Please consider using this plugin.

@kaakaa kaakaa closed this as completed Oct 23, 2018
@hanzei hanzei added the wontfix label Oct 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants