Steps I am following:
/send_otp
- Send otp to given number/token
- generate access token if the provide number and otp are correct- Authorize button - Need to provide the token to give access #Need help here
/show_results
- requires authorization to show results
I am using oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token")
for authorization. The Authorize button is asking to enter username, password, client id and client secret.
How to test from swagger UI? I can use postman with Bearer token, but is it possible to use swagger UI for testing this? How to utilize the Authorize button to provide access to /show_results
API?
/token: route look like
@app.post("/token")
def generate_token(phone_number: str, otp: str):
...
# Return OAuth2 token
return {"access_token": encoded_jwt, "token_type": "bearer"}
/Show_results: route looks like
@app.get("/show_results")
def show_results(token: Optional[str] = Depends(oauth2_scheme)):
...
Authorize button view: