<commit_before>package controllers

import (
	"fmt"
	"log"
	"net/http"

	"golang.org/x/oauth2"
	"golang.org/x/oauth2/github"
)

var conf = &oauth2.Config{
	ClientID:     "508322171059309cedad",
	ClientSecret: "<KEY>",
	Scopes:       []string{},
	Endpoint:     github.Endpoint,
}

// OAuthAuthorize makes the user login
func OAuthAuthorize(w http.ResponseWriter, req *http.Request) {
	url := conf.AuthCodeURL("state", oauth2.AccessTypeOnline)
	http.Redirect(w, req, url, http.StatusFound)
}

// OAuthCallback handles the callback from GitHub
func OAuthCallback(w http.ResponseWriter, req *http.Request) {
	// Get the code from the response
	code := req.FormValue("code")

	// Exchange the received code for a token
	token, err := conf.Exchange(oauth2.NoContext, code)
	if err != nil {
		log.Fatal(err)
	}

	// client := conf.Client(oauth2.NoContext, token)

	fmt.Fprintf(w, "Token: %s!", token)
}<commit_msg>Even more semi-working oauth logins<commit_after>package controllers

import (
	"fmt"
	"log"
	"net/http"

	"github.com/google/go-github/github"
	"golang.org/x/oauth2"
	oauth2github "golang.org/x/oauth2/github"
)

var conf = &oauth2.Config{
	ClientID:     "508322171059309cedad",
	ClientSecret: "<KEY>",
	Scopes:       []string{},
	Endpoint:     oauth2github.Endpoint,
}

// OAuthAuthorize makes the user login
func OAuthAuthorize(w http.ResponseWriter, req *http.Request) {
	url := conf.AuthCodeURL("state", oauth2.AccessTypeOnline)
	http.Redirect(w, req, url, http.StatusFound)
}

// OAuthCallback handles the callback from GitHub
func OAuthCallback(w http.ResponseWriter, req *http.Request) {
	// Get the code from the response
	code := req.FormValue("code")

	// Exchange the received code for a token
	token, err := conf.Exchange(oauth2.NoContext, code)
	if err != nil {
		log.Fatal(err)
	}

	httpClient := conf.Client(oauth2.NoContext, token)
	githubClient := github.NewClient(httpClient)
	user, _, err := githubClient.Users.Get("")

	fmt.Fprintf(w, "Token: %s!", user.String())
}
{'fraction_non_alphanumeric': 0.14056224899598393, 'fraction_numerical': 0.02208835341365462, 'mean_word_length': 4.343163538873995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2066956', 'n_tokens_mistral': 754, 'n_tokens_neox': 703, 'n_words': 165}