Unable to issue access tokens for existing users

I have the SendBird Chat installed and working with my ReactNative app for months now. I am attempting to install and use SendBird Calls. Even though SB Chat supports authentication with only a user id (via connect method), apparently the SB Calls requires an access token. At this point I already have several users of my app, thus several users with SB accounts. None of those users have ever been issued an SB access token because up until this point I didn’t need to issue one. When I attempt to issue an access token for an existing user, via instructions found here, I am always getting a 400 server error, particularly a 400401 INVALID_API_TOKEN error. How can I issue a token for an existing user that never had a token issued if I am required to pass a token to issue a token? What am I missing here?

react-native: v0.62.2
sendbird: v3.0.108
sendbird-calls: v1.1.1

That error likely means you don’t have the application level API token in the header when trying to issue an access token for a user. This API token can be your master API token or a secondary API token, but either way this is an application level token and not specific to any particular user. More information about the headers required to make a platform API call can be found here.

You can issue an access token for a user as seen here or you can issue a token through the Sendbird Dashboard as seen in the attached screenshot.

1 Like

This means that this type of action shouldn’t be done from clients (i.e. a mobile or web app), correct? Is there any way a logged in user on a client can authenticate themselves?

Hi @fullStackChris, from the SDK there is no way to the user to authenticate themselves. You would need to provide them with the Session Token or Access Token necessary for them to connect.

Alright, makes sense… I guess what I originally should have asked is if it is possible to get a user’s avatar / profile picture URL without any sort of authentication - that’s the use case I need. Is there a public endpoint somewhere to get that (given I have their Sendbird ID) or will I have to do it via an admin account from our server? If the question and/or answer is too complicated, I’m happy to open a new thread.

There is no unauthenticated API call that you can make to obtain a users profile_url. You would either nee to connect the user to the SDK, or you would need to call a get request to the /v3/users/{user_id} endpoint (User | Chat Platform API | Sendbird Docs). Having a public URL that does not require any authentication to access could be considered a privacy issue.

Sounds good. One final question then: does the profile picture URL also change when a user changes their profile picture? Or is the URL preserved and only the file replaced (assuming they have the same sendbird ID the whole time)

The profile_url will update each time the image is updated as it correlates to a specific resource in AWS. The url is not static.

Hmmm ok… do the older one(s) get invalidated after some time, or would they still work? :slight_smile: