QuickBlox / quickblox-android-sdk

QuickBlox Android SDK includes code snippets with main use cases and framework JAR library.
BSD 3-Clause "New" or "Revised" License
417 stars 697 forks source link

Forbidden user: if create private dialog to a user #464

Closed Ashokkumar-iOS closed 3 years ago

Ashokkumar-iOS commented 7 years ago

Help avoid duplicate issue reports, check [existing issues](link to issues section of repo)

Environment details (Operating system, browser information, SDK version) Android 5.0 to 7.0

Did this work before? Yes

Expected behavior Create private dialog to user should work

Actual behavior its throwing "Forbidden user" exception

Logs (please, use github gist)

                                                 === REQUEST ==== d72def66-8966-4675-8db7-8d9563bff77c ===
                                                 REQUEST
                                                     POST https://api.quickblox.com/chat/Dialog.json
                                                 HEADERS
                                                     QuickBlox-REST-API-Version=0.1.1
                                                     QB-SDK=Android 3.4
                                                     QB-Token=83e5f623d5a285c3b64f606ef0ff84623900eeb0
                                                 PARAMETERS
                                                     type=3
                                                     occupants_ids=35210286
                                                 INLINE
                                                     POST https://api.quickblox.com/chat/Dialog.json?type=3&occupants_ids=35210286

                                                 *** RESPONSE *** d72def66-8966-4675-8db7-8d9563bff77c ***
                                                 STATUS : 422 
                                                 HEADERS
                                                     X-Runtime=0.007880
                                                     Cache-Control=no-cache
                                                     QuickBlox-REST-API-Version=0.1.1
                                                     X-Android-Selected-Protocol=http/1.1
                                                     Set-Cookie=_mkra_ctxt=5d430d1b1db1b502d5ac9c87545cca8b--422; path=/; max-age=5; HttpOnly; secure
                                                     QB-Token-ExpirationDate=2017-10-16 12:12:27 +0000
                                                     Status=422 Unprocessable Entity
                                                     X-Request-Id=bf669ee4-0f98-43f2-bfce-351880a87b95
                                                     X-Android-Response-Source=NETWORK 422
                                                     Connection=Close
                                                     X-Android-Sent-Millis=1508149409763
                                                     Content-Type=application/json; charset=utf-8
                                                     Date=Mon, 16 Oct 2017 10:23:31 GMT
                                                     X-Content-Type-Options=nosniff
                                                     Content-Length=45
                                                     Server=openresty/1.9.15.1
                                                     Strict-Transport-Security=max-age=31536000
                                                     X-XSS-Protection=1; mode=block
                                                     X-Frame-Options=SAMEORIGIN
                                                     X-Android-Received-Millis=1508149410418
                                                     Access-Control-Allow-Origin=*
                                                 BODY
                                                     '{"errors":{"base":["Forbidden. Need user."]}}'

Steps to reproduce the behavior

Any others comments?

tatanka987 commented 7 years ago

you should use method QBUsers.signIn(user) for create session with user, after that you will can create dialogs, get users etc.

dinhthaidaica commented 6 years ago

I got the same problem when using Android SDK. I had already logged user in. And I'm sure that QBChatService.getInstance().getUser() return not-null object And QBChatService.getInstance().isLoggedIn() return true

RomanPronin commented 6 years ago

To be able to use QuickBlox REST API you have to be sign in with QBUsers.signIn(user). In order to use QuickBlox Chat API you must use chatService.login(qbUser).

ghost commented 3 years ago

Hello QuickBlox customer,

This is Nikolay from QuickBlox support.

The issue was closed as it is outdated.

Please check the relevant section of our documentation here: https://docs.quickblox.com/docs/android-chat-dialogs

Also, please update the SDK to the latest version: https://github.com/QuickBlox/quickblox-android-sdk-releases/releases/tag/3.9.11

Additionally, please check our new samples: https://docs.quickblox.com/docs/code-samples#chat-samples

If it is still relevant after reviewing the updated information, feel free to open a new issue.

Have a nice day.