Bootstrap starter template
+Use this document as a way to quickly start any new project.
All you get is this text and a mostly barebones HTML document.
diff --git a/eve_auth/views.py b/eve_auth/views.py index 91ea44a..1f5ed3c 100644 --- a/eve_auth/views.py +++ b/eve_auth/views.py @@ -1,3 +1,36 @@ -from django.shortcuts import render +from typing import Union +import requests +from django.contrib.auth.models import User +from django.shortcuts import render +from allauth.socialaccount.providers import eveonline # Create your views here. +from allauth.socialaccount.models import SocialAccount, SocialToken, SocialApp + +from requests.auth import HTTPBasicAuth + + + +def hello(request): + return render( + request, + 'base.html', + {} + ) + + +def renew_token(request, account: Union[SocialAccount, User]): + if account is User: + account = SocialAccount.objects.get(user=account) + token = SocialToken.objects.get(account=account) + app = SocialApp.objects.get(provider='eveonline') + req = requests.post( + url='https://login.eveonline.com/oauth/token', + data={ + 'grant_type': 'refresh_token', + 'refresh_token': token.token_secret + }, + auth=HTTPBasicAuth(app.client_id, app.secret) + ) + token.token = req.json()['access_token'] + token.save() diff --git a/eve_verify/settings.py b/eve_verify/settings.py index 194bb1b..85c6824 100644 --- a/eve_verify/settings.py +++ b/eve_verify/settings.py @@ -43,6 +43,7 @@ INSTALLED_APPS = [ 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.eveonline', + 'bootstrap4', ] MIDDLEWARE = [ @@ -133,8 +134,16 @@ USE_TZ = True STATIC_URL = '/static/' +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, "static"), +] -EVE_CLIENT_ID = '2f398f82dbdb43ff86c60effcc423f93' -EVE_SECRET_KEY = 'xnaKPpbqoDH9LO8aE7FVq5Xb4aqI6guXeTBkdMB4' +SITE_ID = 1 -SITE_ID = 1 \ No newline at end of file +SOCIALACCOUNT_STORE_TOKENS = True + +SOCIALACCOUNT_PROVIDERS = { + 'eveonline': { + 'SCOPE': ['publicData', 'esi-characters.read_corporation_roles.v1', 'characterAccountRead'] + } +} \ No newline at end of file diff --git a/eve_verify/urls.py b/eve_verify/urls.py index 7955d42..f76486d 100644 --- a/eve_verify/urls.py +++ b/eve_verify/urls.py @@ -16,8 +16,10 @@ Including another URLconf from django.conf.urls import url from django.contrib import admin from django.urls import path, include -import allauth +import eve_auth.views + urlpatterns = [ path('admin/', admin.site.urls), url(r'^accounts/', include('allauth.urls')), + path('', eve_auth.views.hello) ] diff --git a/requirements.txt b/requirements.txt index e11314d..62741de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ Django requests -django-allauth \ No newline at end of file +django-allauth +django-bootstrap4 \ No newline at end of file diff --git a/static/css/custom.css b/static/css/custom.css new file mode 100644 index 0000000..8a60244 --- /dev/null +++ b/static/css/custom.css @@ -0,0 +1,7 @@ +body { + padding-top: 5rem; +} +.starter-template { + padding: 3rem 1.5rem; + text-align: center; +} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..256361a --- /dev/null +++ b/templates/base.html @@ -0,0 +1,38 @@ +{% load bootstrap4 %} + + +
+ + + + + + +Use this document as a way to quickly start any new project.
All you get is this text and a mostly barebones HTML document.