1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-07 06:25:23 +02:00

github config from table

This commit is contained in:
Elliott Stoneham 2016-06-02 07:46:30 +01:00
parent 3d79cdd95e
commit 768bedb701
2 changed files with 14 additions and 9 deletions

View file

@ -33,9 +33,4 @@ func (*github) Meta() TypeMeta {
func init() {
sectionsMap["github"] = &github{}
// TODO make both soft and alterable at runtime
gh.ClientID = "8574d0c34142dcdc53f6"
gh.ClientSecret = "628e04d1575e234fbf477ff7b5f7dbfc95074c9e"
}

View file

@ -23,13 +23,23 @@ import (
"strings"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/documize/api/request"
// vendored locally
gogithub "github.com/google/go-github/github"
"golang.org/x/oauth2"
)
var ClientID, ClientSecret string
const configKey = "SECTION-GITHUB"
func clientID() string{
return request.ConfigString(configKey,"clientID")
}
func clientSecret() string{
return request.ConfigString(configKey,"clientSecret")
}
func authorizationCallbackURL() string{
return request.ConfigString(configKey,"authorizationCallbackURL")
}
type GithubT struct {
@ -458,8 +468,8 @@ func Callback(res http.ResponseWriter, req *http.Request) error {
state := req.URL.Query().Get("state")
ghurl := "https://github.com/login/oauth/access_token"
vals := "client_id=" + ClientID
vals += "&client_secret=" + ClientSecret
vals := "client_id=" + clientID()
vals += "&client_secret=" + clientSecret()
vals += "&code=" + code
vals += "&state=" + state