added oauth_handler to prepare for reddit oauth code flow

This commit is contained in:
harmacist 2022-10-01 13:16:56 -05:00
parent 7414c9e366
commit 6f0a2db5ea
13 changed files with 108 additions and 15 deletions

37
.idea/workspace.xml generated
View File

@ -5,7 +5,10 @@
</component>
<component name="ChangeListManager">
<list default="true" id="798f8ce3-a144-41d0-ac8c-0356b7d8115c" name="Changes" comment="Initial Commit - Flask">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/oauth_handler/urls.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sinkhole/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sinkhole/settings.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/sinkhole/urls.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/sinkhole/urls.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -43,6 +46,7 @@
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="RESET_MODE" value="HARD" />
<option name="SET_USER_NAME_GLOBALLY" value="false" />
</component>
<component name="HttpClientSelectedEnvironments">
@ -57,20 +61,20 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"last_opened_file_path": "C:/Users/willi/PycharmProjects/sinkhole/src/sinkhole/settings.py",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"rest.client.default.execution.environment": "development",
"settings.editor.selected.configurable": "com.jetbrains.django.DjangoModulesConfigurable"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/willi/PycharmProjects/sinkhole/src/sinkhole/settings.py&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;rest.client.default.execution.environment&quot;: &quot;development&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;com.jetbrains.django.DjangoModulesConfigurable&quot;
}
}]]></component>
}</component>
<component name="PyConsoleOptionsProvider">
<option name="myPythonConsoleState">
<console-settings module-name="sinkhole" is-module-sdk="true">
@ -79,6 +83,11 @@
</console-settings>
</option>
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\willi\PycharmProjects\sinkhole\src\oauth_handler\templates\oauth_handler" />
</key>
</component>
<component name="RunManager" selected="Django Server.Django Server">
<configuration name="reddit_api | Authorize - Oauth Method" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" temporary="true" nameIsGenerated="true" environment="" path="$PROJECT_DIR$/refs/reddit_api.http" requestIdentifier="Authorize - Oauth Method" runType="Run single request">
<method v="2" />

View File

View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class OauthHandlerConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'oauth_handler'

View File

View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View File

@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
{% block bootstrap_header %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT"
crossorigin="anonymous">
{% endblock bootstrap_header %}
<title>{% block title %}{% endblock title %}</title>
{% block head %}
{% endblock head %}
</head>
<body>
{% block body %}
<div class="container">
<h3 class="alert alert-secondary" role="alert">Templated Page</h3>
</div>
{% endblock body %}
{% block bootstrap_footer %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8"
crossorigin="anonymous">
</script>
{% endblock bootstrap_footer %}
</body>
</html>

View File

@ -0,0 +1,9 @@
{% extends 'oauth_handler/base.html' %}
{% block title %}{{ title_string }}{% endblock title %}
{% block body %}
<div class="container">
<h3>If you are not redirected in a few seconds, please click <a href="{% url 'oauth-home' %}">here</a>.</h3>
</div>
{% endblock body %}

View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name='oauth-home'),
path('callback/', views.callback)
]

View File

@ -0,0 +1,20 @@
from django.shortcuts import render
# Create your views here.
def home(request):
return render(
request,
'oauth_handler/base.html',
context={}
)
def callback(request):
return render(
request,
'oauth_handler/callback.html',
context={
'title_string': "This is a test. This is only, a test."
}
)

View File

@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'oauth_handler.apps.OauthHandlerConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',

View File

@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('oauth/', include('oauth_handler.urls'))
]