-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathGenerateAccessToken.cs
36 lines (31 loc) · 1.11 KB
/
GenerateAccessToken.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
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SignNow.Net.Model;
using SignNow.Net.Service;
namespace SignNow.Net.Examples
{
[TestClass]
public partial class OAuth2Examples : ExamplesBase
{
/// <summary>
/// An example of obtaining an access token via OAuth 2.0 service.
/// </summary>
[TestMethod]
public async Task GenerateAccessTokenAsync()
{
var clientId = credentials.ClientId;
var clientSecret = credentials.ClientSecret;
var userLogin = credentials.Login;
var userPassword = credentials.Password;
var oauth = new OAuth2Service(ApiBaseUrl, clientId, clientSecret)
{
ExpirationTime = 60
};
var response = await oauth.GetTokenAsync(userLogin, userPassword, Scope.All)
.ConfigureAwait(false);
Assert.IsNotNull(response);
Assert.IsFalse(string.IsNullOrEmpty(response.AccessToken));
Assert.IsFalse(string.IsNullOrEmpty(response.RefreshToken));
}
}
}