@Summary Get external auth device by ID. @ID get-external-auth-device-by-id @Security CoderSessionToken @Produce json @Tags Git @Param externalauth path string true "Git Provider ID" format(string) @Success 200 {object} codersdk.ExternalAuthDevice @Router /api/v2/external-auth/{externalauth}/device
(rw http.ResponseWriter, r *http.Request)
| 234 | // @Success 200 {object} codersdk.ExternalAuthDevice |
| 235 | // @Router /api/v2/external-auth/{externalauth}/device [get] |
| 236 | func (*API) externalAuthDeviceByID(rw http.ResponseWriter, r *http.Request) { |
| 237 | config := httpmw.ExternalAuthParam(r) |
| 238 | ctx := r.Context() |
| 239 | |
| 240 | if config.DeviceAuth == nil { |
| 241 | httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ |
| 242 | Message: "Git auth device flow not supported.", |
| 243 | }) |
| 244 | return |
| 245 | } |
| 246 | |
| 247 | deviceAuth, err := config.DeviceAuth.AuthorizeDevice(r.Context()) |
| 248 | if err != nil { |
| 249 | httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{ |
| 250 | Message: "Failed to authorize device.", |
| 251 | Detail: err.Error(), |
| 252 | }) |
| 253 | return |
| 254 | } |
| 255 | |
| 256 | httpapi.Write(ctx, rw, http.StatusOK, deviceAuth) |
| 257 | } |
| 258 | |
| 259 | func (api *API) externalAuthCallback(externalAuthConfig *externalauth.Config) http.HandlerFunc { |
| 260 | return func(rw http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected