-
-
Notifications
You must be signed in to change notification settings - Fork 14
Using Authentication methods
Details about how to obtain access tokens using OAuth 2.0
For all the account-related usages, make sure you include the Account Model namespace:
using Tradier.Client.Models.Authentication;
Access tokens are the keys used for API access. These tokens should be protected like passwords! You can obtain an access token by exchanging an authorization code. This call is authenticated using Basic Authentication implemented in HTTP specification. Your application consumer key will serve as your username and the consumer secret the password.
Due to the OAuth specification, this API endpoint uses HTTP Basic Authentication. You can learn more about HTTP Basic Authentication on Wikipedia or directly reference the specification.
Token authentication = await client.Authentication.CreateAccessToken("<CODE>");
Refresh tokens can be exchanged for access tokens without a customer reauthorizing the application. These tokens should be protected like passwords! You will obtain a refresh token in the same response as an access token.
Due to the OAuth specification, this API endpoint uses HTTP Basic Authentication. You can learn more about HTTP Basic Authentication on Wikipedia or directly reference the specification.
Token authentication = await client.Authentication.RefreshAccessToken("<TOKEN>");
using System.Threading.Tasks;
using Tradier.Client;
using Tradier.Client.Models.Authentication;
namespace MyConsoleApp
{
class Program
{
static async Task Main(string[] args)
{
TradierClient client = new TradierClient("<TOKEN>");
Token authentication = await client.Authentication.CreateAccessToken("<CODE>");
Token authentication2 = await client.Authentication.RefreshAccessToken("<TOKEN>");
}
}
}
Created by Henrique Tedeschi and Vitali Karmanov. See our Disclaimer. Check the API documentation on Tradier API.