GithubHelp home page GithubHelp logo

bearle / django-web3-auth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from atereshkin/django-web3-auth

87.0 5.0 40.0 1.5 MB

A pluggable Django app that enables login/signup via an Ethereum wallet (a la CryptoKitties)

License: Other

Python 62.90% JavaScript 13.49% HTML 19.11% Makefile 4.50%
django django-application ethereum web3 metamask authentification python dapp

django-web3-auth's Introduction

Django-Web3-Auth

https://travis-ci.org/Bearle/django-web3-auth.svg?branch=master

django-web3-auth is a pluggable Django app that enables login/signup via an Ethereum wallet (a la CryptoKitties). The user authenticates themselves by digitally signing the session key with their wallet's private key.

https://github.com/Bearle/django-web3-auth/blob/master/docs/_static/web3_auth_test.gif?raw=true

Documentation

The full documentation is at https://django-web3-auth.readthedocs.io.

Example project

https://github.com/Bearle/django-web3-auth/tree/master/example

You can check out our example project by cloning the repo and heading into example/ directory. There is a README file for you to check, also.

Features

  • Web3 API login, signup
  • Web3 Django forms for signup, login
  • Checks ethereum address validity
  • Uses random token signing as proof of private key posession
  • Easy to set up and use (just one click)
  • Custom auth backend
  • VERY customizable - uses Django settings, allows for custom User model
  • Vanilla Javascript helpers included

Quickstart

Install Django-Web3-Auth with pip:

pip install django-web3-auth

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'web3auth.apps.Web3AuthConfig',
    ...
)

Set 'web3auth.backend.Web3Backend' as your authentication backend:

AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'web3auth.backend.Web3Backend'
]

Set your User model's field to use as ETH address provider:

WEB3AUTH_USER_ADDRESS_FIELD = 'username'

And if you have some other fields you want to be in the SignupForm, add them too:

WEB3AUTH_USER_SIGNUP_FIELDS = ['email',]

Add Django-Web3-Auth's URL patterns:

from web3auth import urls as web3auth_urls


urlpatterns = [
    ...
    url(r'^', include(web3auth_urls)),
    ...
]

Add some javascript to handle login:

<script src="{% static 'web3auth/js/web3auth.js' %}"></script>
function startLogin() {
  if (typeof web3 !== 'undefined') {
    checkWeb3(function (loggedIn) {
      if (!loggedIn) {
        alert("Please unlock your web3 provider (probably, Metamask)")
      } else {
        var login_url = '{% url 'web3auth:web3auth_login_api' %}';
        web3Login(login_url, console.log, console.log, console.log, console.log, console.log, function (resp) {
          console.log(resp);
          window.location.replace(resp.redirect_url);
        });
      }
    });

  } else {
    alert('web3 missing');
  }
}

You can access signup using {% url 'web3auth:web3auth_signup' %}.

If you have any questions left, head to the example app https://github.com/Bearle/django-web3-auth/tree/master/example

Important details and FAQ

  1. If you set a custom address field (WEB3AUTH_USER_ADDRESS_FIELD), it MUST be unique (unique=True).

This is needed because if it's not, the user can register a new account with the same address as the other one, meaning that the user can now login as any of those accounts (sometimes being the wrong one).

2. How do i deal with user passwords or Password is not set There should be some code in your project that generates a password using User.objects.make_random_password and sends it to a user email. Or, even better, sends them a 'restore password' link. Also, it's possible to copy signup_view to your project, assign it a url, and add the corresponding lines to set some password for a user.

  1. Why do i have to sign a message? It's not needed in MyEtherWallet or other DApps!

The main reason is that when using a DApp, you most likely don't have an account on the website, it's accessible only with web3 (Metamask). When using web3 only to sign into user account, it is necessary to prove your identity with a private key (e.g. sign a random message), because when we have backend we can't trust any user just by his knowledge of the public address. Signed message proves that user possesses the private key, associated with the address.

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

django-web3-auth's People

Contributors

atereshkin avatar delneg avatar st1vms avatar sukicz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

django-web3-auth's Issues

Unable to install example app in latest version

  • Django-Web3-Auth version: 0.1.3
  • Django version: 2.0.6
  • Python version: 3.8.5
  • Operating System: ubuntu (wsl windows 10)

Description

Trying to install the example program, hits an issues with requirements conflicting.

What I Did

pip install -r requirements.txt
Obtaining file:///mnt/c/Users/user/PycharmProjects/web3auth (from -r requirements.txt (line 5))
Collecting coverage==4.4.1
  Using cached coverage-4.4.1-cp38-cp38-linux_x86_64.whl
Collecting mock>=1.0.1
  Using cached mock-4.0.3-py3-none-any.whl (28 kB)
Collecting flake8>=2.1.0
  Using cached flake8-3.9.1-py2.py3-none-any.whl (73 kB)
Collecting tox>=1.7.0
  Using cached tox-3.23.0-py2.py3-none-any.whl (85 kB)
Collecting codecov>=2.0.0
  Using cached codecov-2.1.11-py2.py3-none-any.whl (16 kB)
Collecting tox-travis>=0.12
  Using cached tox_travis-0.12-py2.py3-none-any.whl (10 kB)
Collecting Django==2.0.6
  Using cached Django-2.0.6-py3-none-any.whl (7.1 MB)
Collecting packaging==16.8
  Using cached packaging-16.8-py2.py3-none-any.whl (23 kB)
Collecting ethereum==2.3.2
  Using cached ethereum-2.3.2-py3-none-any.whl
Collecting rlp==2.0.1
  Using cached rlp-2.0.1-py2.py3-none-any.whl (20 kB)
Collecting eth_utils>=1.0.3
  Using cached eth_utils-1.10.0-py3-none-any.whl (24 kB)
Collecting pytz
  Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting pyparsing
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting six
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting repoze.lru
  Using cached repoze.lru-0.7-py3-none-any.whl (10 kB)
Collecting future
  Using cached future-0.18.2-py3-none-any.whl
Collecting PyYAML
  Using cached PyYAML-5.4.1-cp38-cp38-manylinux1_x86_64.whl (662 kB)
INFO: pip is looking at multiple versions of packaging to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of django to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of coverage to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of django-web3-auth to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install -r requirements.txt (line 5) and django-web3-auth because these package versions have conflicting dependencies.

The conflict is caused by:
    django-web3-auth 0.1.3 depends on rlp==2.0.1
    ethereum 2.3.2 depends on rlp<2.0.0 and >=1.0.1

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

some error about this function “sig_to_vrs()”

  • Django-Web3-Auth version:
  • Django version:
  • Python version:
  • Operating System:

Description

error with this function
def sig_to_vrs(sig):
# sig_bytes = bytes.fromhex(sig[2:])
r = int(sig[2:66], 16)
s = int(sig[66:130], 16)
v = int(sig[130:], 16)
return v, r, s

error:
ValueError: invalid literal for int() with base 16: 'x13a288e1f37f887232928280b1be88f4c9fd26893bf39675a74aa89125ebc20'

my signdata:
‘0x13a288e1f37f887232928280b1be88f4c9fd26893bf39675a74aa89125ebc20b5902dd94311502aabf8499e063b74b044a8d72f4748b3e217eef4e289984db701b’

Unable to install django-web3-auth

Requirement already satisfied: asgiref<4,>=3.3.2 in c:\users\mohsin\appdata\local\programs\python\python39\lib\site-packages (from Django>=2.0->django-web3-auth==0.1.5) (3.4.1)
Requirement already satisfied: sqlparse>=0.2.2 in c:\users\mohsin\appdata\local\programs\python\python39\lib\site-packages (from Django>=2.0->django-web3-auth==0.1.5) (0.4.1)
Requirement already satisfied: eth-hash<0.4.0,>=0.3.1 in c:\users\mohsin\appdata\local\programs\python\python39\lib\site-packages (from eth_utils>=1.0.3->django-web3-auth==0.1.5) (0.3.2)
Requirement already satisfied: eth-typing<3.0.0,>=2.2.1 in c:\users\mohsin\appdata\local\programs\python\python39\lib\site-packages (from eth_utils>=1.0.3->django-web3-auth==0.1.5) (2.2.2)
Requirement already satisfied: cytoolz<1.0.0,>=0.10.1 in c:\users\mohsin\appdata\local\programs\python\python39\lib\site-packages (from eth_utils>=1.0.3->django-web3-auth==0.1.5) (0.11.0)
Requirement already satisfied: toolz>=0.8.0 in c:\users\mohsin\appdata\local\programs\python\python39\lib\site-packages (from cytoolz<1.0.0,>=0.10.1->eth_utils>=1.0.3->django-web3-auth==0.1.5) (0.11.1)
Requirement already satisfied: mypy-extensions>=0.4.1 in c:\users\mohsin\appdata\local\programs\python\python39\lib\site-packages (from py_ecc->ethereum==2.3.2->django-web3-auth==0.1.5) (0.4.3)
Requirement already satisfied: cached-property<2,>=1.5.1 in c:\users\mohsin\appdata\local\programs\python\python39\lib\site-packages (from py_ecc->ethereum==2.3.2->django-web3-auth==0.1.5) (1.5.2)
Using legacy 'setup.py install' for django-web3-auth, since package 'wheel' is not installed.
Using legacy 'setup.py install' for ethereum, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pyethash, since package 'wheel' is not installed.
Using legacy 'setup.py install' for future, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pbkdf2, since package 'wheel' is not installed.
Installing collected packages: pyethash, py-ecc, pbkdf2, future, coincurve, ethereum, django-web3-auth
Running setup.py install for pyethash ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\mohsin\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Mohsin\AppData\Local\Temp\pip-install-lausirkt\pyethash_6005ac2402734f45b9e3f0187f54226f\setup.py'"'"'; file='"'"'C:\Users\Mohsin\AppData\Local\Temp\pip-install-lausirkt\pyethash_6005ac2402734f45b9e3f0187f54226f\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\Mohsin\AppData\Local\Temp\pip-record-ksjjftmi\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\mohsin\appdata\local\programs\python\python39\Include\pyethash'
cwd: C:\Users\Mohsin\AppData\Local\Temp\pip-install-lausirkt\pyethash_6005ac2402734f45b9e3f0187f54226f
Complete output (27 lines):
running install
running build
running build_ext
building 'pyethash' extension
creating build
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\Release
creating build\temp.win-amd64-3.9\Release\src
creating build\temp.win-amd64-3.9\Release\src\libethash
creating build\temp.win-amd64-3.9\Release\src\python
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\mohsin\appdata\local\programs\python\python39\include -Ic:\users\mohsin\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcsrc/libethash/internal.c /Fobuild\temp.win-amd64-3.9\Release\src/libethash/internal.obj -Isrc/ -std=gnu99 -Wall
cl : Command line warning D9002 : ignoring unknown option '-std=gnu99'
internal.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt.h(212): warning C4668: '__cplusplus' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h(1833): warning C4710: 'int sprintf_s(char *const ,const size_t,const char *const ,...)': function not inlined
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h(1833): note: see declaration of 'sprintf_s'
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\mohsin\appdata\local\programs\python\python39\include -Ic:\users\mohsin\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcsrc/libethash/io.c /Fobuild\temp.win-amd64-3.9\Release\src/libethash/io.obj -Isrc/ -std=gnu99 -Wall
cl : Command line warning D9002 : ignoring unknown option '-std=gnu99'
io.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt.h(212): warning C4668: '__cplusplus' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h(1833): warning C4710: 'int sprintf_s(char *const ,const size_t,const char *const ,...)': function not inlined
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h(1833): note: see declaration of 'sprintf_s'
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\mohsin\appdata\local\programs\python\python39\include -Ic:\users\mohsin\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /Tcsrc/libethash/io_win32.c /Fobuild\temp.win-amd64-3.9\Release\src/libethash/io_win32.obj -Isrc/ -std=gnu99 -Wall
cl : Command line warning D9002 : ignoring unknown option '-std=gnu99'
io_win32.c
c1: fatal error C1083: Cannot open source file: 'src/libethash/io_win32.c': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\mohsin\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Mohsin\AppData\Local\Temp\pip-install-lausirkt\pyethash_6005ac2402734f45b9e3f0187f54226f\setup.py'"'"'; file='"'"'C:\Users\Mohsin\AppData\Local\Temp\pip-install-lausirkt\pyethash_6005ac2402734f45b9e3f0187f54226f\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\Mohsin\AppData\Local\Temp\pip-record-ksjjftmi\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\mohsin\appdata\local\programs\python\python39\Include\pyethash' Check the logs for full command output.

Example app has missing url configuration

Ekran Resmi 2021-07-11 23 27 33

Environment:


Request Method: GET
Request URL: http://localhost:8000/login/

Django Version: 2.0.6
Python Version: 3.9.6
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'web3auth']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']


Template error:
In template /private/tmp/django-web3-auth/example/templates/web3auth/base.html, error at line 46
   Reverse for 'web3auth_signup' not found. 'web3auth_signup' is not a valid view function or pattern name.
   36 : 
   37 :     <div class="collapse navbar-collapse" id="navbarSupportedContent">
   38 :       <ul class="navbar-nav mr-auto">
   39 :         <li class="nav-item">
   40 :           <a class="nav-link" href="{% url 'login' %}">Login</a>
   41 :         </li>
   42 :         <li class="nav-item">
   43 :           <a class="nav-link" href="{% url 'autologin' %}">Autologin</a>
   44 :         </li>
   45 :         <li class="nav-item">
   46 :           <a class="nav-link" href=" {% url 'web3auth_signup' %} ">Signup</a>
   47 :         </li>
   48 :       </ul>
   49 :     </div>
   50 :   </nav>
   51 : 
   52 : </div>
   53 : <div class="container">
   54 : 
   55 :   {% if messages %}
   56 :     {% for message in messages %}


Traceback:

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/core/handlers/base.py" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/private/tmp/django-web3-auth/example/example/urls.py" in login
  24.         return render(request, 'web3auth/login.html')

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/shortcuts.py" in render
  36.     content = loader.render_to_string(template_name, context, request, using=using)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/loader.py" in render_to_string
  62.     return template.render(context, request)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/backends/django.py" in render
  61.             return self.template.render(context)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/base.py" in render
  175.                     return self._render(context)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/base.py" in _render
  167.         return self.nodelist.render(context)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/base.py" in render
  943.                 bit = node.render_annotated(context)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/base.py" in render_annotated
  910.             return self.render(context)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/loader_tags.py" in render
  155.             return compiled_parent._render(context)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/base.py" in _render
  167.         return self.nodelist.render(context)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/base.py" in render
  943.                 bit = node.render_annotated(context)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/base.py" in render_annotated
  910.             return self.render(context)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/template/defaulttags.py" in render
  447.             url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/urls/base.py" in reverse
  90.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))

File "/private/tmp/django-web3-auth/example/venv/lib/python3.9/site-packages/django/urls/resolvers.py" in _reverse_with_prefix
  636.         raise NoReverseMatch(msg)

Exception Type: NoReverseMatch at /login/
Exception Value: Reverse for 'web3auth_signup' not found. 'web3auth_signup' is not a valid view function or pattern name.

Django - Web3 Rest API AUTH

  • Django-Web3-Auth version: lts
  • Django version: 3.2.6
  • Python version: 3.8
  • Operating System: Ubuntu WSL

Description

Trying to implement a Django REST API version using this, need suggestions on workflow

What I Did

I haven't tried anything yet

Uncaught TypeError: web3.eth is undefined (web3auth.js)

  • Django-Web3-Auth version: 0.1.6
  • Django version: 2.0.6
  • Python version: 3.8.10
  • Operating System: WSL

Description

Run example demo

What I Did

I followed the example README.md.

Running server logs the following in console when attempting to click login:
Uncaught TypeError: web3.eth is undefined
checkWeb3 http://localhost:8000/static/web3auth/js/web3auth.js:56
startLogin http://localhost:8000/login/:88
onclick http://localhost:8000/login/:1
web3auth.js:56:5

// web3auth.js
function checkWeb3(callback) {
    // web3 = new Web3(window.ethereum)
    web3.eth.getAccounts(function (err, accounts) { // Check for wallet being locked
        if (err) {
            throw err;
        }
        callback(accounts.length !== 0);
    });
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.