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

Auth fails because no visitor_global_id in response #1

Open
sergey124 opened this issue Feb 9, 2023 · 1 comment
Open

Auth fails because no visitor_global_id in response #1

sergey124 opened this issue Feb 9, 2023 · 1 comment

Comments

@sergey124
Copy link

Authentication call from frontend fails in Python app because there's no visitor_global_id in response.

The response from /api/v5/public/orgs/<organization_id>/auth is:

{
  "visitor_id": "???",
  "visitor_secret_id": "???",
  "organization_id": "???",
  "socket_url": "wss://messagerouter.giosg.com/websocket",
  "access_token": "???",
  "expires_at": "2023-02-06T23:35:29.120Z",
  "expires_in": 28800,
  "minimal_bar_version": 2
}

while in the API docs visitor_global_id is present: https://docs.giosg.com/api_reference/giosg_live/giosg_public_http_api/general/

The error is:

Internal Server Error: /api/chats/
Traceback (most recent call last):
File "projects\giosg_sample_app\ext_connectivity_example\chat_app\views.py", line 44, in perform_create
existing_visitor = models.Visitor.objects.get(visitor_name=serializer.validated_data["visitor_name"])
File "Anaconda3\envs\py38\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "Anaconda3\envs\py38\lib\site-packages\django\db\models\query.py", line 439, in get
raise self.model.DoesNotExist(
chat_app.models.Visitor.DoesNotExist: Visitor matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "Anaconda3\envs\py38\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "Anaconda3\envs\py38\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "Anaconda3\envs\py38\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "Anaconda3\envs\py38\lib\site-packages\rest_framework\viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "Anaconda3\envs\py38\lib\site-packages\rest_framework\views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "Anaconda3\envs\py38\lib\site-packages\rest_framework\views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "Anaconda3\envs\py38\lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception
raise exc
File "Anaconda3\envs\py38\lib\site-packages\rest_framework\views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "projects\giosg_sample_app\ext_connectivity_example\chat_app\views.py", line 38, in create
self.perform_create(serializer)
File "projects\giosg_sample_app\ext_connectivity_example\chat_app\views.py", line 59, in perform_create
giosg_visitor_global_id=visitor["visitor_global_id"],
KeyError: 'visitor_global_id'

I hotfixed it by adding a line

visitor["visitor_global_id"] = visitor["visitor_secret_id"]

in ext_connectivity_example/chat_app/views.py after

visitor = api.create_giosg_visitor(settings.GIOSG_ORGANIZATION_ID, settings.GIOSG_ROOM_ID)
@sergey124
Copy link
Author

sergey124 commented Feb 9, 2023

As it's the most up-to-date sample app, maybe it would be possible to check if the code or API documentation corresponds to the actual server response.
@ariniinimaki @mentholi

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

No branches or pull requests

1 participant