forked from ringcentral/RingCentral.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormUrlEncodedTest.cs
37 lines (35 loc) · 1.4 KB
/
FormUrlEncodedTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using Xunit;
namespace RingCentral.Tests
{
// Note: this test class is for API troubleshooting only
// Please do not reference the code here, it should not be used in production
public class FormUrlEncodedTest
{
[Fact]
public async void GetAndRevokeToken()
{
using (var rc = new RestClient(
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_ID"),
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_SECRET"),
Environment.GetEnvironmentVariable("RINGCENTRAL_SERVER_URL")
))
{
var tokenInfo = await rc.Restapi(null).Oauth().Token().Post(new GetTokenRequest
{
grant_type = "password",
username = Environment.GetEnvironmentVariable("RINGCENTRAL_USERNAME"),
extension = Environment.GetEnvironmentVariable("RINGCENTRAL_EXTENSION"),
password = Environment.GetEnvironmentVariable("RINGCENTRAL_PASSWORD"),
});
Assert.NotNull(tokenInfo);
Assert.True(tokenInfo.access_token.Length > 0);
var r = await rc.Restapi(null).Oauth().Revoke().Post(new RevokeTokenRequest
{
token = tokenInfo.access_token
});
Assert.Empty(r);
}
}
}
}