Question

C# SDK and RingCentral JWT

  • 11 April 2022
  • 2 replies
  • 697 views

  • New Participant
  • 3 replies

Hello Experts

Is there a basic working .Net sample on how to let a client authorize our app so we can get the access token and move forward from there?

We are able to get the token via password auth.

https://developers.ringcentral.com/guide/authentication/jwt-flow does not have sample payload necessary.

Your help is much appreciated.


2 replies

Userlevel 1

This is a public function in the .NET SDK

public Task<TokenInfo> Authorize(string jwt)
{
    var getTokenRequest = new GetTokenRequest
    {
        grant_type = "urn:ietf:params:oauth:grant-type:jwt-bearer",
        assertion = jwt
    };
    return Authorize(getTokenRequest);
}

So you can authenticate your app like this

...
static RestClient restClient;
static void Main(string[] args)
{
    restClient = new RestClient(
                "RC_CLIENT_ID, "RC_CLIENT_SECRET", "RC_SERVER_URL");
    restClient.Authorize("JWT_TOKEN").Wait();
    ...
}

Hey Phong

Thank you for your response.


The way I understand is that I would have page (aspx) that would have a button which will pass parameters to RC and RC will redirect back with the approval payload (json).


My experience with JWT authentication is very limited, so may be this might be a silly question. But what is the order of calls to be made? Also, which RingCentral library to use (there are two or three that I see on nuget).


Again, my apologies if these are too obvious of a question to be asking here.

Reply