Skip to content

Instantly share code, notes, and snippets.

@kamilhism
kamilhism / oktaverify2totp.md
Created September 10, 2022 16:18
Get TOTP secret key for Okta Verify
  1. Get the content of the QR for Okta Verify app setup. It looks like this: oktaverify://[email protected]/?t=XXXXX&f=YYYYY&s=https://DOMAIN.okta.com&issuer=DOMAIN.okta.com&isIdxEnabled=true
  2. Replace XXXXX, YYYYY and DOMAIN to your values in curl below:
curl --request POST \
  --url https://DOMAIN.okta.com/idp/authenticators \
  --header 'Accept: application/json; charset=UTF-8' \
  --header 'Accept-Encoding: gzip, deflate' \
  --header 'Authorization: OTDT XXXXX' \
  --header 'Content-Type: application/json; charset=UTF-8' \
library(shiny)
library(jsonlite)
# we'll store received data in a local json file
write_json(list(), "data.json")
post_handler <- function(req, response) {
# we'll catch everything that's POST for this demo but you'll want to make
# sure you don't step on shiny's built-in POST handlers
# (I'm pretty sure this handler is called after shiny's handlers but :shrug:)
super_split <- function(data, ...) {
  dots <- rlang::quos(...)
  for (var in seq_along(dots)) {
    var_name <- rlang::as_name(dots[[var]])
    data <- purrr:::map_depth(
      data, 
      var - 1, 
      function(xs) split(xs, xs[var_name])
    )