Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Use Unauthorized access message #1

Open
wants to merge 1 commit into
base: api-key
Choose a base branch
from

Conversation

yahyayouness
Copy link

problem:

Wrong message for 401.

Solution:

Use Unautorized access message instead if 403 forbidden message

Instead of forbidden 403
@@ -10,7 +10,7 @@ const API_KEY = '395a9cce-6ffc-48b8-8372-b95089c3abc6'
app.get('/formations', (req, res) => {
const apiKeyFromHeader = req.headers['x-api-key']
if (API_KEY !== apiKeyFromHeader) {
res.status(401).send({code: 401, error: 'FORBIDDEN'})
res.status(401).send({code: 401, error: 'Unauthorized: Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription'})
Copy link
Author

@yahyayouness yahyayouness Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(suggestion) On peut utiliser la spec https://jsonapi.org/format/#errors pour l'objet error et rappeler l'importance qu'il soit standard pour une meilleure gestion d'erreur coté client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant