AgoraIO-Usecase / Online-KTV

KTV with your fans together everywhere
74 stars 34 forks source link

Invalid Token error on joinChannel() call #49

Open edouardperrin opened 2 years ago

edouardperrin commented 2 years ago

Hello, I am trying to run the project on iOS and I face a token issue, maybe because of my misunderstanding. I have set up correctly my AgoraIO account and created my test project. I have also set up the LeanCloud account correctly.

So the app starts normally and I wish to create a room by tapping the related button in the CreateRoom view. At this point, I always get the error "Invalid token" when joining the channel/room. LeanCloud table entries are created successfully (and new rooms appear in the Main view of the app). App Certificate is enabled on my AgoraIO project. So that I believe I need to set the Token in BuildConfig along with my AppId.

image

My first question is : Based on my AgoraIO project, which one should I use in the OnlineKTV project when I join the channel ? BuildConfig.Token or BuildConfig.RtmToken ?

In the previous screenshot, in addition to the AppID, there are : Token : under "Status", which is a static one : I imagine this token is the RTM token, can you confirm ? RTC token : which is a valid for 24h, and generated and linked to a specific channel name/id.

My second question is : Can you confirm that I don't need this RTC token ? As we can create many channels with different name/id in the application, I believe that I don't have to use it.

Finally, I updated the call to joinChannel() in RtcServer to use BuildConfig.Token (nil in source code), updated with the "general" Token (not the RTC token). Is it correct then ?

image

Actually I tried each scenario using one or the other, an I always face the error "Invalid Token" error. Can you help me to understand how these tokens are used ? I don't know what to try now, I wish to get some help in order to evaluate this AgoraIO product.

Thank you!

plutoless commented 2 years ago

@edouardperrin the master branch requires backend service deployment with leancloud. to use the app with rtm/rtc only, use this branch instead, https://github.com/AgoraIO-Usecase/Online-KTV/tree/localmusic there is a file called Config.swift under Core folder. you can fill in appid/rtc token/rtm token there.

Just be aware, this project has been written to work and optimize with domestic china service providers, so if you are having problems experiencing it, feel free to get in touch with our support team.

edouardperrin commented 2 years ago

Thanks for your quick reply! Yeah, I understood that it was linked to Leancloud backend, and this part seems to be OK, as the needed entities are created on Leadcloud correctly. And that is great as it gives me an idea how I could integrate this inside my own backend in the future.

image

My concern is more about tokens, where I don't really get what I am doing wrong. I generate a RTC token with a specific channelID on the AgoraIO console and I copy/paste the AppId and that (not expired) RTC token on BuildConfig, but I always face "The token is invalid" (and after that "SDK refused")

But Ok, maybe I miss something with Leancloud backend. I am going to have a look at the other branch, thank you for the link.