Hello Guys’
I am trying to make a POC with the two factors authentication with the Auth0 PUSH method.
The problem is (I think) that I never receive that push, so my application is going in an infinite loop of :“error_description”:"Authorization pending: please repeat the request in a few seconds.
Basically what I am doing is :
– Try to make a user grant password and it got denied with the error : mfa_required which is normal and I receive a mfa_token.
– I am sending a query to /mfa/associate with the auth0 value : authenticator_types": [“oob”],“oob_channels”: [“auth0”]}’
– Now I receive an OOB_Token and I use it to do the /mfa/challenge call ( mfa_token + oob_token).
And finally , I receive the answer : Authorization pending: please repeat the request in a few seconds.And it’s an infinite loop of doom.
Can someone help me on that, I must have not understand clearly what to do … and can’t get it …
Here is the python code that I have made to make the POC :
def do_user_auth(self,username,password):
print("--------- DO USER AUTH -----")
scopes = "openid openid profile read:authenticators email address phone perm_clause_view perm_clause_create perm_clause_edit perm_clause_publish"
headers = {"Content-Type": "application/json","Accept": "text/plain"}
data = '{"grant_type":"password","scope":"'+scopes+'","client_secret":"'+self.AUTH_CLIENT_SECRET+'","client_id":"'+self.AUTH_CLIENT_ID+'","username":"'+username+'","password":"'+password+'"}'
r = requests.post("https://"+self.AUTH_DOMAIN+"/oauth/token", data=data,headers=headers)
answer = json.loads(r.content)
print(r.content)
if "error" in answer:
if answer["error"] == 'mfa_required':
oob_code = self.associate_application_post(answer["mfa_token"])
self.do_two_factor_auth_call(answer["mfa_token"],oob_code)
def do_two_factor_auth_call(self,a_mfa_token,a_otp_code):
print("--------- DO TWO FACTOR CALL AUTH -----")
data = '{"client_secret":"'+self.AUTH_CLIENT_SECRET+'","client_id":"'+self.AUTH_CLIENT_ID+'","mfa_token": "'+a_mfa_token+'","grant_type": "http://auth0.com/oauth/grant-type/mfa-oob","oob_code": "'+a_otp_code+'","binding_code": "000000"}'
headers = {"Content-Type": "application/json","Accept": "text/plain"}
r = requests.post("https://"+self.AUTH_DOMAIN+"/oauth/token", data=data,headers=headers)
print(r.content)
decoded = r.content.decode('utf-8')
if "error" in decoded and "authorization_pending" in decoded:
print("waiting some seconds")
time.sleep(15)
self.do_two_factor_auth_call(a_mfa_token,a_otp_code)
def associate_application_post(self,a_mfa_token):
print("--------- DO ASSOCIATE CALL AUTH -----")
headers = {"Content-Type": "application/json","Accept": "text/plain","Authorization":"Bearer "+a_mfa_token}
data = '{"client_secret":"'+self.AUTH_CLIENT_SECRET+'","client_id":"'+self.AUTH_CLIENT_ID+'","authenticator_types": ["oob"],"oob_channels": ["auth0"]}'
r = requests.post("https://"+self.AUTH_DOMAIN+"/mfa/associate", data=data,headers=headers)
print(r.content)
answer = json.loads(r.content)
return answer["oob_code"]
Cheers,