Missing Authentication Token, C# tutorial

Hello, I’m knew to Algorand. Im following along with the .net tutorial. I’m getting the error Missing Authentication Token. In the tutorial I’m not sure if the Auth token I need is one from the Algorand api or from the 3rd party api?

I see now it’s from purestake.

Thanks in advance

I have my API token now but Im still getting this error: Error calling AccountInformation: {“message”:“Missing Authentication Token”}

Can you post your code here between triple backquotes ```?
(Replace the token by XXXX)

        AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN);
        public ViewModel ViewModel { get; set; }
        public MainWindow()
        {
            InitializeComponent();

            TestApi();

            ViewModel = new ViewModel();
            DataContext = ViewModel;
        }

        private async void Button_Click(object sender, RoutedEventArgs e)
        {            
            await Task.Run(() =>
            {
                var accountInfo = algodApiInstance.AccountInformation("VYFF3MXAXWGHNIAEUVINZZHEW2MH5HKTXEACXUTZ3HHADIBPT5ATJGR6K4");
                //ViewModel.AccountAddress = string.Format("Account Balance: " + accountInfo.Amount + " MicroAlgos");
                string address = string.Format("Account Balance: " + accountInfo.Amount + " MicroAlgos");
                MessageBox.Show(address);
            });
        }

What is ALGOD_API_ADDR?

Ive tried this sample code as well

            try
            {
                var supply = algodApiInstance.GetSupply();
                Console.WriteLine("Total Algorand Supply: " + supply.TotalMoney);
                Console.WriteLine("Online Algorand Supply: " + supply.OnlineMoney);
            }
            catch (ApiException e)
            {
                Console.WriteLine("Exception when calling algod#getSupply: " + e.Message);
            }

            try
            {
                var transParams = algodApiInstance.TransactionParams();
                Console.WriteLine("Transaction Params: " + transParams.ToJson());
            }
            catch (ApiException e)
            {
                throw new Exception("Could not get params", e);
            }

https://testnet-algorand.api.purestake.io/ps2

I’m fixing your post. You need to use triple backquotes, not triple quotes

My bad, thanks allot

How are you importing AlgodApi?
Are you using v2?
Can you print ALGOD_API_TOKEN to be sure it matches the token you got on https://developer.purestake.io?

Can you try in console:

curl -X GET “https://testnet-algorand.api.purestake.io/ps2/v2/status” -H “x-api-key:WriteHereYourApiKey”

I imported the AlgoApi via nuget.
How can I determine if Im using v2 or not?
Here’s my printout: ``` catchpoint":"",“catchpoint-acquired-blocks”:0,“catchpoint-processed-accounts”:0,“catchpoint-total-accounts”:0,“catchpoint-total-blocks”:0,“catchpoint-verified-accounts”:0,"

What using line do you have on top of your .cs file?

using Algorand.Algod.Api;
not sure why my post are not coming through

You need to close the triple backquotes

```
my code
```

Can you show all the using involving Algorand?

It should be:

using Algorand.V2;

and nothing else most likely.

See

1 Like

Thanks allot for your help, my problem was that I didn’t have .V2. The example I was following did not state that.

Thanks

Which example did you use so that we can fix it?

I just noticed this, either it was updated or I missed these instructions because the video I originally watched was based off of this tutorial which has the correct sdk version. Algorand Developer Portal

Here’s the video: Algorand UWP App (Smart Contract) - YouTube