Search code examples
c#agora.ioagora-web-sdk-ng

Generating dynamic key for Agora.io using C#


I am using c#, mvc.

Agora sample github doesn`t have C#.

I can't get any solution to generate dynamic key using C#.

I try too may solution but can't got proper solution.

If any one has experience on Agora.io, please help me.


Solution

  • Agora offers a C# implementation: https://github.com/AgoraIO/Tools/blob/master/DynamicKey/AgoraDynamicKey/csharp

    example of token generation using C#

    AccessToken token = AccessToke(appID, appCertificate, channelName, uid);
    token.AddPrivilege(Privileges.kJoinChannel);
    token.AddPrivilege(Privileges.kPublishAudioStream);
    token.AddPrivilege(Privileges.kPublishVideoStream);
    string token = token.Build();
    

    for more info on the .Build() function look at AccessToken.cs and for more privileges that can be set, take a look at Privileges.cs.