string ALGOD_API_ADDR_TESTNET = "https://testnet-algorand.api.purestake.io/ps2";
string ALGOD_API_TOKEN_TESTNET = API KEY FOUND in PURESTAKE;
AlgodApi algodApiInstances = new AlgodApi(ALGOD_API_ADDR_TESTNET, ALGOD_API_TOKEN_TESTNET);
var c = _address.Text;
try
{
var accountInfo = algodApiInstances.AccountInformation(c.ToString());
Debug.WriteLine("");
_balance.Text = $"{accountInfo.Amount}";
await DisplayAlert("Account Address", $"MicroAlgos: {accountInfo.Amount}", "OK");
} catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
Having done as explicitly said in tutorials and in YouTube video, however, I keep getting the "missing authentication tokenĀ° error.
Also with breakpoint, my AlgodApi algodApiInstances shows nulla as access token.
Indeed I signed up and logged and retrieved my API token. I insert it in initialization for the AlgodApi algodApiInstances object. However auth token keeps on being null.
var boh = new Configuration();
boh.AddDefaultHeader("X-API-Key", ALGOD_API_TOKEN_TESTNET);
boh.AccessToken = ALGOD_API_TOKEN_TESTNET;
boh.BasePath = ALGOD_API_ADDR_TESTNET;
IDictionary<string, string> apiKey = new Dictionary<string, string>()
{
["X-API-Key"] = ALGOD_API_TOKEN_TESTNET
};
boh.ApiKey = apiKey;
boh.Password = _wPass; //wallet password
AlgodApi algodApiInstances = new AlgodApi(ALGOD_API_ADDR_TESTNET, ALGOD_API_TOKEN_TESTNET);
algodApiInstances.Configuration = boh;
I added configuration object with access token (i used the apiToken) and default header and so on
And still no actual improvement.
Is C# V2 of API actually usable?
Also note that AlgodApi is old, and you should use DefaultApi to access the algodā¦
Also note that there are 2 algorand nuget packages, one from RileyGe and one from Frankā¦ I recommend to use the one from Frank as there is a lot of new work done, is better to use and is under active developmentā¦ For example if you use the boxes, it is the only way to go as they were introduce in past year.
Thank you so much for your care and your quick responsesā¦ However, unluckily, still no improvements.
var httpClient =
HttpClientConfigurator.ConfigureHttpClient(ALGOD_API_ADDR,
ALGOD_API_TOKEN);
DefaultApi algodApiInstance = new DefaultApi(httpClient);
This section, for example, relies on V2 modules (only DefaultApi in V2 requires the httpClient as arg), while this:
var accountInfo = await
algodApiInstance.AccountInformationAsync(srcAccount.Address.ToString(), null, null);
seems to require the previous version.
I changed it in:
var accountInfo = await algodApiInstance.AccountsAsync(srcAccount.Address.ToString(), null);
adopting the V2 methods, however I still get an error about the http request.
I also tried to ācopy ānā pasteā the whole thing from github, but indeed, again, nothing works.
Maybe I need to perform a downgrade of the NuGet module for Algorandā¦ But I am close to give up
Welcome to Algorand!
You need to follow the instructions in the #welcome Discord channel if you have not done so, so you can access all the Discord channels.
This requires in particular solving a CAPTCHA sent by DM.