Hi !
I’m using Authentication API with MetaMask using Python and Django on my project (https://docs.moralis.io/authentication-api/evm/how-to-sign-in-with-metamask-python-django).
I have an issue connecting with a Ledger wallet, the status code of the request in verify_message() is 400 instead of 201.
It works fine with standard MetaMask wallet (hotwallet).
Any idea how to solve that ?
For information:
def verify_message(request):
data = json.loads(request.body)
REQUEST_URL = ‘https://authapi.moralis.io/challenge/verify/evm’
x = requests.post(
REQUEST_URL,
json=data,
headers={‘X-API-KEY’: API_KEY})
if x.status_code == 201:
# user can authenticate
eth_address=json.loads(x.text).get(‘address’)
eth_address = eth_address.lower()
try:
user = User.objects.get(username=eth_address)
except User.DoesNotExist:
user = User(username=eth_address)
user.is_staff = False
user.is_superuser = False
user.save()
if user is not None:
if user.is_active:
login(request, user)
request.session[‘auth_info’] = data
request.session[‘verified_data’] = json.loads(x.text)
return JsonResponse({‘user’: user.username})
else:
return JsonResponse({‘error’: ‘account disabled’})
else:
return JsonResponse(json.loads(x.text))