Skip to content

Commit

Permalink
Update how-to-sign-in-with-metamask-python-django.md
Browse files Browse the repository at this point in the history
Tutorial edits as a companion to the pull request proposed [here](MoralisWeb3/demo-apps#71)
  • Loading branch information
imperorrp authored Mar 6, 2023
1 parent 00e5b34 commit f35eb84
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ from django.shortcuts import render, redirect
from django.http import HttpResponse, JsonResponse
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
from datetime import datetime, timedelta, timezone

API_KEY = 'WEB3_API_KEY_HERE'
# this is a check to make sure the the API key was set
Expand All @@ -126,14 +127,21 @@ def request_message(request):
data = json.loads(request.body)
print(data)

#setting request expiration time to 1 minute after the present->
present = datetime.now(timezone.utc)
present_plus_one_m = present + timedelta(minutes=1)
expirationTime = str(present_plus_one_m.isoformat())
expirationTime = str(expirationTime[:-6]) + 'Z'
print(f'ExpirationTime = {expirationTime}')

REQUEST_URL = 'https://authapi.moralis.io/challenge/request/evm'
request_object = {
"domain": "defi.finance",
"chainId": 1,
"address": data['address'],
"statement": "Please confirm",
"uri": "https://defi.finance/",
"expirationTime": "2023-01-01T00:00:00.000Z",
"expirationTime": expirationTime,
"notBefore": "2020-01-01T00:00:00.000Z",
"timeout": 15
}
Expand Down Expand Up @@ -356,4 +364,4 @@ After the message is signed and the authentication is successful, you can see th

![](/img/content/0a87357-profile_info_1.webp)

![User Profile Page](/img/content/03f26e6-profile_info_3.webp)
![User Profile Page](/img/content/03f26e6-profile_info_3.webp)

0 comments on commit f35eb84

Please sign in to comment.