Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
138 views
in Technique[技术] by (71.8m points)

rest - How to pass information to webpage which API is unauthorized?

Webpage calls API A. Service behind API A acquires token for external API B and sends a request.

API A responds 401 Unauthorized when user is not authorized using token from webpage. But it also responds 401 when acquired token for API B lacks authorization.

This is not a good pattern, because webpage needs to behave differently for these two cases.

How should the response from API A look like (right status code etc.) in case API B is unauthorized, so it could be handled in the front-end? There are many options, but I couldn't find any textbook example for that situation.

question from:https://stackoverflow.com/questions/66047857/how-to-pass-information-to-webpage-which-api-is-unauthorized

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...