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

Accept getToken callback in AgoraConnectionData #153

Open
iamriajul opened this issue Aug 18, 2023 · 5 comments
Open

Accept getToken callback in AgoraConnectionData #153

iamriajul opened this issue Aug 18, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@iamriajul
Copy link

Is your feature request related to a problem? Please describe.
I've my agora-token-service deployed but is not exposed as a public API, What we do is we have our API endpoint which verifies authentication and type of user the currently authenticated, and other business logic and then based on that data we generate a token using the agora-token-service, and also we deny with error message in-case the authenticated user doesn't satisfy business logic or don't have access to that channel.

Describe the solution you'd like
I want to be able to pass a parameter something like this:

final connectionDataProvider = FutureProvider.autoDispose((ref) {
   // The API has middleware, which attaches things like Authorization Bearer Token, to authenticate current user.
   final api = ref.watch(apiProvider);
   final callInfo = ref.watch(callInfoProvider);
   return AgoraConnectionData(
    appId: "<APP_ID>",
    channelName: callInfo.roomId,
    uid: callInfo.userId,
    getToken: () async => (await api.getVideoCallToken(callInfo.roomId)).token,
  );
}); 

Describe alternatives you've considered
Currently thinking to pass my token using tempToken parameter, but I'm not sure about this solution. As I've seen Temp Token generated from the Agora dashboard has a longer expiry time (around 1 day). but my token generated from my API Endpoint has only 5 minutes of expiry time.

Additional context
I'm using
Agora UIKit Flutter: 1.3.6
agora-token-service: 1.4.2 ( using this Docker Image: https://hub.docker.com/r/iamriajul/agora-token-service )

Thanks.

@iamriajul iamriajul added the enhancement New feature or request label Aug 18, 2023
@maxxfrazer
Copy link
Contributor

passing a closure would be a really nice option! the only awkward thing is it would then have three separate options; token url, temp token, and a “get token” callback.

this could be done with ios/swift using an enum with an associated types:

enum TokenType {
    case tempToken(String)
    case tokenUrl(String)
    case getToken((channel: String) -> String?)
}

obj.token = .getToken({})
// or .tempToken(“abcde”)

is something similar possible in Dart?

@iamriajul
Copy link
Author

is something similar possible in Dart?

I don't think dart support that.

@iamriajul
Copy link
Author

And changing the existing API for ConnectionData would cause an issue.

I've seen that the SDK uses the tokenUrl to generate tokens for both RTC & RTM (if enabled).

To support both scenarios we might need to add two separate callback parameters.

  • getRtcToken(String channel, int uid) nullable
  • getRtmToken(String channel, int uid) nullable

Another thing I've noticed is that the SDK is using the deprecated routes for agora-token-service, The SDK should be using the POST /getToken endpoint for generating both types of token, which I think should be resolved first.

@iamriajul
Copy link
Author

Another thing I've noticed is that the SDK is using the deprecated routes for agora-token-service, The SDK should be using the POST /getToken endpoint for generating both types of token, which I think should be resolved first.

If you want I can make a PR on this issue.

@maxxfrazer
Copy link
Contributor

damn @iamriajul, you're pretty quick - I only added the /getToken endpoint earlier this month 😅 feel free to make a PR if you get chance. all the projects will eventually migrate so that's be great to kick off with this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants