Possible to regenerate QR code for existing token with API?

157 views
Skip to first unread message

g8rf...@gmail.com

unread,
Jun 29, 2015, 10:28:21 AM6/29/15
to lin...@googlegroups.com
Is it possible to regenerate the QR code for an existing token using the API?

I tinkered with admin/init a bit to see if I could pass it an existing token serial and get the json response that includes a QR code but I couldn't get it to work. Is this even possible?

Moustapha Amadou Diouf

unread,
Jun 30, 2015, 4:29:33 AM6/30/15
to lin...@googlegroups.com, g8rf...@gmail.com
Hello,

Yes it is very possible.
If you send the admin/init request correctly, you will get a json that has result and more importantly othurl and googleurl if I am not mistaken.
You can then extract the googleurl (if you are looking for a google authenticator qr code) by getting the img (value) which you can use to display to code.
Can you post your code. It is really hard to help you if you do not.

You will find below an example of (Java) request,followed by the answer from the server.

URL url2 = new URL("http://localhost:5001/admin/init?description=web%20ui%20generated&user=${username}&realm=arya&pin=1234&otplen=6&genkey=1&type=totp&session=" + cookieValue)
URLConnection conn2 = url2.openConnection()
conn2.setRequestProperty("Cookie", cookie)
InputStream inputStream = conn2.inputStream

def response2 = JSON.parse(inputStream.newReader())
def img = response2.detail.googleurl.img

Look at your request and make sure you are setting the parameters correctly.
Then look at the JSON you receive to extract the img.

Best regards.
Madmous
Reply all
Reply to author
Forward
0 new messages