Skip to content

Instantly share code, notes, and snippets.

@BNPrashanth
Created September 13, 2019 09:02
Show Gist options
  • Save BNPrashanth/8288c8c6d5e94e640360266c2b074028 to your computer and use it in GitHub Desktop.
Save BNPrashanth/8288c8c6d5e94e640360266c2b074028 to your computer and use it in GitHub Desktop.
/*
HandleLogin Function
*/
func HandleLogin(w http.ResponseWriter, r *http.Request, oauthConf *oauth2.Config, oauthStateString string) {
URL, err := url.Parse(oauthConf.Endpoint.AuthURL)
if err != nil {
logger.Log.Error("Parse: " + err.Error())
}
logger.Log.Info(URL.String())
parameters := url.Values{}
parameters.Add("client_id", oauthConf.ClientID)
parameters.Add("scope", strings.Join(oauthConf.Scopes, " "))
parameters.Add("redirect_uri", oauthConf.RedirectURL)
parameters.Add("response_type", "code")
parameters.Add("state", oauthStateString)
URL.RawQuery = parameters.Encode()
url := URL.String()
logger.Log.Info(url)
http.Redirect(w, r, url, http.StatusTemporaryRedirect)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment