fix: Add more extensive oauth scope
This commit is contained in:
		| @@ -23,7 +23,7 @@ var config = oauth2.Config{ | |||||||
| 	ClientSecret: "XN98Q~Wrp1RfakkihA1BaTKfokOSX9fuB01unanr", | 	ClientSecret: "XN98Q~Wrp1RfakkihA1BaTKfokOSX9fuB01unanr", | ||||||
| 	Endpoint:     microsoft.AzureADEndpoint("ceeae22e-f163-4ac9-b7c2-45972d3aed4f"), | 	Endpoint:     microsoft.AzureADEndpoint("ceeae22e-f163-4ac9-b7c2-45972d3aed4f"), | ||||||
| 	RedirectURL:  "https://alias.spamasaurus.com/callback", | 	RedirectURL:  "https://alias.spamasaurus.com/callback", | ||||||
| 	Scopes:       []string{"User.Read"}, | 	Scopes:       []string{"User.Read", "Profile"}, | ||||||
| } | } | ||||||
|  |  | ||||||
| func rootHandler(w http.ResponseWriter, r *http.Request) { | func rootHandler(w http.ResponseWriter, r *http.Request) { | ||||||
| @@ -33,10 +33,11 @@ func rootHandler(w http.ResponseWriter, r *http.Request) { | |||||||
|  |  | ||||||
| func callbackHandler(w http.ResponseWriter, r *http.Request) { | func callbackHandler(w http.ResponseWriter, r *http.Request) { | ||||||
| 	// Handle the callback after successful authentication | 	// Handle the callback after successful authentication | ||||||
| 	code := r.URL.Query().Get("code") | 	token, err := config.Exchange(r.Context(), r.URL.Query().Get("code")) | ||||||
| 	token, err := config.Exchange(r.Context(), code) |  | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		w.Write([]byte(spew.Sdump(err))) | 		if retrieveErr, ok := err.(*oauth2.RetrieveError); ok { | ||||||
|  | 			w.Write([]byte(retrieveErr.ErrorDescription + " (" + retrieveErr.ErrorCode + ")")) | ||||||
|  | 		} | ||||||
| 		http.Error(w, "Error exchanging code for token", http.StatusInternalServerError) | 		http.Error(w, "Error exchanging code for token", http.StatusInternalServerError) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user