前提・実現したいこと
django(python)でzoomus.apiを使用し、
ビデオ会議ができるようなシステムを作りたいと思っています。
なのでまずhtmlからuserIDを入力後対象の会議リストを取得しようとしています。
useIDなどを組み込んだトークン作成ができません。
何かご存知の方おりましたらお願いいたします。
該当のソースコード
views.py
from django.shortcuts import render from django.http import HttpResponse import jwt import requests def index(request): params={ 'mail':'', } return render(request,'api/index.html',params) def about(request): mail = request.post['mail'] cosole.log('mail') ApiKey = 'zzz' ApiSercret = 'zzz' #token作成 payload = { 'iss': 'ApiKey', 'exp': datetime.now().strftime("%Y/%m/%d %H:%M:%S") + 10000 } token = jwt.sign(payload,APISecret) options = { uri:'https://api.zoom.us/v2/users/'+{mail}+'/meetings', qs:{ status:'active' }, auth:{ 'bearer':token }, headers:{ 'User-Agent':'Zoom-api-Jwt-Request', 'content-type':'application/json' }, json:true } if requests.post(options): console.log('User has', response) console.log(token) console.log(JSON.stringify(resp, null, 2)) else: console.log('API call failed, reason ', err) return render(request,'/about.html',token)
index.html
<!doctype html> <html lang="ja"> <head> <meta charset="utf-8" /> <title>api</title> </head> <body> <h1>userID</h1> <form acition="{%url 'about'%}"method="post"> {% csrf_token %} <p>userID</p> <input type="tel" placeholder="UserID" value="{{ 'mail' }}"> <input type="submit" value="認証する"> </form> </body> </html>
urls.py
from django.contrib import admin from django.urls import path from rest_framework_jwt.views import obtain_jwt_token from . import views #�NjL urlpatterns = [ path('admin/', admin.site.urls), path('',views.index,name='index'), path('about/',views.about,name='about') #path('jwt-token/', obtain_jwt_token), #path('ping', views.PingViewSet.as_view()), # �NjL ]
試したこと
以下サイトを使用し、トークンの作成を試みています。
http://r9.hateblo.jp/entry/2018/01/30/081534
また以下サイトを参照しトークンの作成は確認できました。
https://qiita.com/gaku3601/items/19f734fedd5fe19e5c77
###参照しているサイト
https://marketplace.zoom.us/docs/guides/authorization/jwt/authentication
https://qiita.com/simanezumi1989/items/f990871168fff11d509d
https://qiita.com/uasi/items/cfb60588daa18c2ec6f5
使用JWT
https://github.com/lepture/authlib
フレームワークとapiを使うのが初めてなので
コード上でおかしいところがありましたらご指摘お願いいたします。
まだ回答がついていません
会員登録して回答してみよう