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

Swagger document and Django Rest API's not working as expected #1495

Closed
gururajdori opened this issue May 5, 2020 · 2 comments
Closed

Swagger document and Django Rest API's not working as expected #1495

gururajdori opened this issue May 5, 2020 · 2 comments
Assignees
Labels
bug Something isn't working
Projects
Milestone

Comments

@gururajdori
Copy link

gururajdori commented May 5, 2020

Pulled CVAT with commit ID of 011c4aa

    commit 011c4aa675381e12a45a7be35d02464f7d6ead8c (HEAD, tag: v1.0.0-beta.2, 
    origin/release-1.0.0)
    Author: Nikita Manovich <nikita.manovich@intel.com>
    Date:   Thu Apr 30 22:09:28 2020 +0300

    Update changelog.

Built Docker and brought up CVAT services

    sudo docker-compose up --build -d

Created superuser of Django

    sudo docker exec -it cvat bash -ic 'python3 manage.py createsuperuser'

But I'm not able to access swagger documents. I tried with http://localhost:8080/api/swagger/ but the browser is redirecting me to http://localhost:3000

However, I got the OpenAPI document at http://localhost:8080/api/docs

I started using API as specified in the document - Following is my python script

import requests

url = "http://localhost:8080/api/v1/auth/login"

payload = "{\n    \"password\": \"test123\",\n    \"username\": \"gururaj\",\n    \"email\": \"gururaj@dori.ai\"\n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic Og==',
  'Content-Type': 'text/plain',
  'Cookie': 'csrftoken=KQuMhzzvtU7Zv1o9EqxfBhAxNzKSrXPFLe7NF0DKmd50IS5XnvyaYetz9f8lx2ZT'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))

API Response

{
    "detail": "Invalid username/password."
}

Somewhat I had a doubt about superuser(Admin) is not a CVAT user. So I logged into Django Admin and made changes to the user group by adding the user to annotator, observer, user, and admin
Screen Shot 2020-05-06 at 1 27 57 AM

Something wrong in the steps I'm doing or should it be fixed in the next release?
@nmanovic

@nmanovic nmanovic added the bug Something isn't working label May 6, 2020
@nmanovic nmanovic added this to To do in Server via automation May 6, 2020
@nmanovic nmanovic added this to the 1.0.0-release milestone May 6, 2020
@nmanovic nmanovic self-assigned this May 6, 2020
@iamjeerge
Copy link
Contributor

@nmanovic drf-yasg is expected to serve on Allowed_hosts.
Update ALLOWED_HOSTS to IP of Host machine in the docker-compose.yml file

Creating a pull request shortly to update instructions in README.md file

@nmanovic
Copy link
Contributor

@gururajdori , I will close the issue. It seems you have found a solution and send us PR. Don't hesitate to reopen the issue if it isn't fixed yet.

Server automation moved this from To do to Done May 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Server
  
Done
Development

No branches or pull requests

3 participants