Fakultas Ilmu Komputer UI

Commit af8c63ee authored by fakhrilm's avatar fakhrilm
Browse files

refactor sso variable, move them as settings variable

parent ffa13e08
Pipeline #25248 passed with stages
in 6 minutes and 33 seconds
import requests
from django.conf import settings
API_MAHASISWA = "https://api.cs.ui.ac.id/siakngcs/mahasiswa/"
API_RIWAYAT_MAHASISWA = API_MAHASISWA+'{npm}/riwayat/'
API_VERIFY_USER = "https://akun.cs.ui.ac.id/oauth/token/verify/"
def get_access_token(username, password):
try:
url = "https://akun.cs.ui.ac.id/oauth/token/"
......@@ -26,14 +24,14 @@ def get_client_id():
def verify_user(access_token):
print ("#get identity number")
parameters = {"access_token": access_token, "client_id": get_client_id()}
response = requests.get(API_VERIFY_USER, params=parameters)
response = requests.get(settings.API_VERIFY_USER, params=parameters)
print ("response => ", response.json())
return response.json()
def get_summary_user(access_token, npm):
print ("#get summary user => ", npm)
parameters = {"access_token": access_token, "client_id": get_client_id()}
response = requests.get(API_MAHASISWA+str(npm), params=parameters)
response = requests.get(settings.API_MAHASISWA+str(npm), params=parameters)
print ("response => ", response.text)
print ("response => ", response.json())
return response.json()
......@@ -41,7 +39,7 @@ def get_summary_user(access_token, npm):
def get_riwayat_user(access_token, npm):
print ("#get riwayat user => ", npm)
parameters = {"access_token": access_token, "client_id": get_client_id()}
response = requests.get(API_RIWAYAT_MAHASISWA.format(npm=npm), params=parameters)
response = requests.get(settings.API_RIWAYAT_MAHASISWA.format(npm=npm), params=parameters)
print ("response => ", response.text)
print ("response => ", response.json())
return response.json()
......@@ -197,4 +197,8 @@ API_CS_CREDENTIALS = {'user': 'kape', 'password': 'yukcarikape'}
# 250MB - 214958080
# 500MB - 429916160
# 10MB - 10485760
MAX_UPLOAD_SIZE = 5242880
\ No newline at end of file
MAX_UPLOAD_SIZE = 5242880
API_MAHASISWA = "https://api.cs.ui.ac.id/siakngcs/mahasiswa/"
API_RIWAYAT_MAHASISWA = API_MAHASISWA+'{npm}/riwayat/'
API_VERIFY_USER = "https://akun.cs.ui.ac.id/oauth/token/verify/"
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment