I am making an application based on some APIβs and have three input including Phone Number, OTP and Reference ID. When I input the mobile number, then OTP it is completely fine and verifies the OTP but when I try to entry the Reference ID it return that OTP is not verified and says unauthenticated access
import streamlit as st
import base64
import copy, requests
import json
from hashlib import sha256
from collections import Counter
from inputimeout import inputimeout, TimeoutOccurred
import tabulate, copy, time, datetime, requests, sys, os, random
from utils import send_otp,verify_otp,fetch_details
import SessionState
beneficiaries = 'https://cdn-api.co-vin.in/api/v2/appointment/beneficiaries'
st.set_page_config(layout='wide', initial_sidebar_state='collapsed')
@st.cache(allow_output_mutation=True, suppress_st_warning=True)
def fetch_details(request_header):
resp = requests.get(url = beneficiaries,headers = request_header)
print(resp.status_code)
print(resp.content)
resp = resp.json()
return resp
base_request_header = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
}
st.title("PDF Generator")
st.info("This uses CoWiN API's provided by _Govt Of India_")
st.markdown("Also this is all legal and ethical I am doing")
mobile = st.text_input(label = "Phone Number",key="1")
session_state= SessionState.get(checkboxed1=False,checkboxed2=False,checkboxed3=False,n1=0,n2=0)
if len(mobile)!=0 or session_state.checkboxed1 :
session_state.checkboxed1 = True
if session_state.n1==0:
print(session_state.checkboxed1,session_state.checkboxed2,session_state.checkboxed3)
txnID = send_otp(mobile,base_request_header)
print(txnID)
OTP = st.text_input(label = "OTP",key = "2")
if len(OTP)!=0 or session_state.checkboxed2:
session_state.n1+=1
session_state.checkboxed2 = True
if session_state.n2==0:
token = verify_otp(OTP,base_request_header,txnID)
print(token)
bref_id = st.text_input(label = "Beneficiary ID",key = "3")
if len(bref_id)!=0 or session_state.checkboxed3 :
session_state.n2+=1
print("Hello")
request_header = copy.deepcopy(base_request_header)
request_header["Authorization"] = f"Bearer {token}"
print(request_header)
print(bref_id)
resp = fetch_details(request_header)
print(resp.content)