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

[83] Create refresh token endpoint #173

Merged

Conversation

jacekkalbarczyk
Copy link
Contributor

User login (auth/login/) endpoint is now returning both access and refresh token. Refresh token can be used to obtain new access token(via /auth/refresh/ route). There is a new endpoint (/auth/revoke-refresh-token/) to revoke refresh tokens (it should occur during logging out). I also added missing ending slashes to existing routes.
Use Postman app for tests.

Endpoints:

Login
(method: POST) /auth/login/
takes raw JSON as a parameter:
{
"username": username,
"password": password
}
If successful, returns access token, refresh token, HTTP status CREATED (201),
otherwise returns message "Not authorized", HTTP status UNAUTHORIZED (401).

Refreshing access token
(method: POST) /auth/refresh/
takes refresh token via Authorization header(Bearer token) as a parameter.

If successful, returns new access token, HTTP status CREATED (201),
If refresh token was revoked returns message "token has been revoked", HTTP status UNAUTHORIZED (401).

Revoking refresh token
(method: DELETE) /auth/revoke-refresh-token/
takes refresh token via Authorization header(Bearer token) as a parameter.

If successful, returns message "Refresh token successfully revoked", HTTP status OK (200).

)

ret = {'access_token': access_token}
return ret, HTTPStatus.CREATED
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we could just use here: return {'access_token': access_token}, HTTPStatus.CREATED

@jacekkalbarczyk jacekkalbarczyk merged commit 8b9bf92 into CodeForPoznan:master Sep 25, 2019
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.

2 participants