Convert user from password to oauth authentication
POST
CoderSessionTokenheader
Coder-Session-Token<token>user*stringUser ID, name, or me
Convert request
application/json- body
password*stringto_type*stringToType is the login type to convert to.
Value in
"""password""github""oidc""token""none"Created
application/json- response
expires_at?stringFormat
date-timestate_string?stringto_type?codersdk.LoginTypeValue in
"""password""github""oidc""token""none"user_id?stringFormat
uuidThe samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X POST \ "$CODER_URL/api/v2/users/{user}/convert-login" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "password": "string", "to_type": ""}'const { CODER_URL, CODER_SESSION_TOKEN } = process.env;const url = `${CODER_URL}/api/v2/users/{user}/convert-login`;const response = await fetch(url, { method: "POST", headers: { "Coder-Session-Token": CODER_SESSION_TOKEN, "Content-Type": "application/json", }, body: JSON.stringify({ password: "string", to_type: "", }),});console.log(response.status, await response.text());import osimport requestsurl = os.environ["CODER_URL"] + "/api/v2/users/{user}/convert-login"token = os.environ["CODER_SESSION_TOKEN"]response = requests.post( url, headers={ "Coder-Session-Token": token, }, json={ "password": "string", "to_type": "", },)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os" "strings")func main() { body := strings.NewReader(`{ "password": "string", "to_type": ""}`) url := os.Getenv("CODER_URL") + "/api/v2/users/{user}/convert-login" token := os.Getenv("CODER_SESSION_TOKEN") req, err := http.NewRequest(http.MethodPost, url, body) if err != nil { panic(err) } req.Header.Set("Coder-Session-Token", token) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, err := io.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Println(resp.Status, string(out))}Example Response201
{ "expires_at": "2019-08-24T14:15:22Z", "state_string": "string", "to_type": "", "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"}