Where can I fid the missing auth token for test-net?

I have this function linked to a button

string ALGOD_API_ADDR_TESTNET = "https://testnet-algorand.api.purestake.io/ps2";
            AlgodApi algodApiInstances = new AlgodApi(ALGOD_API_ADDR_TESTNET, ALGOD_API_TOKEN_TESTNET);
            var c = _address.Text;
                var accountInfo = algodApiInstances.AccountInformation(c.ToString());
                _balance.Text = $"{accountInfo.Amount}";
                await DisplayAlert("Account Address", $"MicroAlgos: {accountInfo.Amount}", "OK"); 
            } catch (Exception ex)

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.

Thanks in advance.

You could try something such as:

const algod_address = "https://node.algoexplorerapi.io" 
const algod_token = ""

This would allow you to run on Mainnet. For testnet with the Purestake address you are using, you would need to log in to Purestake to find you API 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.

only purestake guys uses the tokens for authentication as far as i know… and they use custom header for it … x-api-key

From my experience AlgoNode is the best nodes provider: API

If you really want to use pure stake, this is the way…

const token = 
		'X-API-Key': x_api_key
const server = "https://testnet-algorand.api.purestake.io/ps2";
const serverIdx = "https://testnet-algorand.api.purestake.io/idx2";
const port = "";

// Instantiate the algod wrapper
let algodClient = new algosdk.Algodv2(token, server, port);

Also notice, that you attempted to use AlgodApi instead of newer algosdk.Algodv2

And for the record, the indexer is used to load the account information, not the algod.

What is the algosdk.Algodv2 equivalent in C#?


I tried this

            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?

In this folder is few examples on how to use it… dotnet-algorand-sdk/sdk-examples at master · FrankSzendzielarz/dotnet-algorand-sdk · GitHub

Note that the ConfigureHttpClient method dotnet-algorand-sdk/HttpClientConfigurator.cs at 2ec9d2e8db9f1f7a7f2528a598855f0bb848c36e · FrankSzendzielarz/dotnet-algorand-sdk · GitHub has parameter header where you can supply the x-api-key

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 = 
    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

Try this…

var accountInfo = await algodApiInstance.AlgodClient.AccountInformationAsync(srcAccount.Address.ToString(), null, null);

Also, @FrankS is active on Discord and very friendly and helpful.


Ping me on the dev discord on NET SDK

In the meantime try the examples Algorand .NET SDK (frankszendzielarz.github.io)

Also try adding trailing slash “/” on the end of the purestake base URL and let me know if that affects you.

1 Like

Hi, thanks again!
I added the Algorand channel on Discord but (thanks for understanding I am a newbie there) I cannot find your name (FrankS) yet.

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.