Example: Creating 2FA credentials¶
Frequency of use | Common |
---|---|
Actors |
|
Communication Flow: Kotlin
TwoFactorAuthDescriptions.twoFactorStatus.call(
Unit,
user
).orThrow()
/*
TwoFactorStatusResponse(
connected = false,
)
*/
TwoFactorAuthDescriptions.createCredentials.call(
Unit,
user
).orThrow()
/*
Create2FACredentialsResponse(
challengeId = "CHALLENGE ID",
otpAuthUri = "OTP URI",
qrCodeB64Data = "QR CODE BASE64 ENCODED",
secret = "SECRET",
)
*/
TwoFactorAuthDescriptions.answerChallenge.call(
AnswerChallengeRequest(
challengeId = "CHALLENGE ID",
verificationCode = 999999,
),
user
).orThrow()
/*
Unit
*/
TwoFactorAuthDescriptions.twoFactorStatus.call(
Unit,
user
).orThrow()
/*
TwoFactorStatusResponse(
connected = true,
)
*/
Communication Flow: Curl
# ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------
# Authenticated as user
curl -XGET -H "Authorization: Bearer $accessToken" "$host/auth/2fa/status"
# {
# "connected": false
# }
curl -XPOST -H "Authorization: Bearer $accessToken" "$host/auth/2fa"
# {
# "otpAuthUri": "OTP URI",
# "qrCodeB64Data": "QR CODE BASE64 ENCODED",
# "secret": "SECRET",
# "challengeId": "CHALLENGE ID"
# }
curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/auth/2fa/challenge" -d '{
"challengeId": "CHALLENGE ID",
"verificationCode": 999999
}'
# {
# }
curl -XGET -H "Authorization: Bearer $accessToken" "$host/auth/2fa/status"
# {
# "connected": true
# }