Support for Oauth in API
raphink opened this issue · 5 comments
Authentication tokens cannot be passed using standard OAuth2.
The following code returns a 401 HTTP error, but passes by adding ?token=<mytoken>
to the URL:
package main
import (
"fmt"
"golang.org/x/oauth2"
)
func main() {
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: "<mytoken>"},
)
tc := oauth2.NewClient(oauth2.NoContext, ts)
a, _ := tc.Get("http://localhost:3000/api/v1/repos/<user>/<repo>/issues")
fmt.Printf("%v", a)
}
If this was supported, then https://github.com/google/go-github would work with gogs by just overriding the BaseURL
property of a client.
Gogs had OAuth-support a while back but was removed since no-one wanted to maintain it.
And no, google/go-github wouldn't work since Gogs has a slightly different json-schema 😞
@bkcsoft is there a link to the old commit for oauth2 that was working? there might be some someone interested in looking at or maintaining oauth2. I want to point them to the right resources.
also @unknwon what was wrong with the previous oauth2 implementation? what mistakes would a new maintainer have to avoid to get oauth2 added?
Anyone looking for this feature may benefit from reading these two issues:
#1304
go-gitea/gitea#26
@stevegt thanks for the comment! go-gitea has login/authn oauth2, and commit status apis just merged. I think once you can generate scoped oauth2 tokens that can have read only access to the repo and update commit status, go-gitea would integrate with drone in a similar way that drone integrates with github or bitbucket. exciting!