'''2.2 新增子路由: oauth/urls.py'''
from django.urls import path
from . import views
urlpatterns = [
]'''2.3 在syl/settings.py中新增應用'''
]'''2.4 在syl/urls.py主路由中新增'''
urlpatterns = [
path('oauth/', include('oauth.urls')),
]
urlpatterns = [
path('weibo/', views.weibourl.as_view()), # /oauth/weibo/ 返回微博登入位址
]
1.2 檢視函式: oauth/views.py
from rest_framework.permissions import allowany
from rest_framework.response import response
from rest_framework.views import apiview
from urllib.parse import urlencode
# 生成前端跳轉到微博掃碼頁面的url
class weibourl(apiview):
'''生成微博的登陸頁面路由位址
# 微博oauth認證位址
response_type=code&
redirect_uri= # 獲取code後將code回 調給後端位址
'''# 自定義許可權類
permission_classes = (allowany,)
def post(self, request):
url = '' # 微博授權的 url位址
// 獲取微博登入位址
oauth() }
let url = resp.data.url;
this.weibo_url = url;
})
},
mounted() ,
'''2.2 新增子路由: oauth/urls.py'''
from django.urls import path
from . import views
urlpatterns = [
]'''2.3 在syl/settings.py中新增應用'''
]'''2.4 在syl/urls.py主路由中新增'''
urlpatterns = [
path('oauth/', include('oauth.urls')),
]
urlpatterns = [
path('weibo/', views.weibourl.as_view()), # /oauth/weibo/ 返回微博登入位址
]
1.2 檢視函式: oauth/views.py
from rest_framework.permissions import allowany
from rest_framework.response import response
from rest_framework.views import apiview
from urllib.parse import urlencode
# 生成前端跳轉到微博掃碼頁面的url
class weibourl(apiview):
'''生成微博的登陸頁面路由位址
# 微博oauth認證位址
response_type=code&
redirect_uri= # 獲取code後將code回 調給後端位址
'''# 自定義許可權類
permission_classes = (allowany,)
def post(self, request):
url = '' # 微博授權的 url位址
// 獲取微博登入位址
oauth() }
let url = resp.data.url;
this.weibo_url = url;
})
},
mounted() ,
前後端聯調,生成微博授權URL介面
2.2 新增子路由 oauth urls.py from django.urls import path from import views urlpatterns 2.3 在syl settings.py中新增應用 2.4 在syl urls.py主路由中新增 urlpatterns path o...
生成微博授權URL
目錄2.生成微博授權url介面 3.測試生成微博授權url介面 2.2 新增子路由 oauth urls.py from django.urls import path from import views urlpatterns 2.3 在syl settings.py中新增應用 2.4 在syl ...
生成微博授權url
2.2 新增子路由 oauth urls.py from django.urls import path from import views urlpatterns 2.3 在syl settings.py中新增應用 2.4 在syl urls.py主路由中新增 urlpatterns path o...