Got "Token not found or expired" in local ttn environment

Hello everyone.

I got in trouble when I try to use go-app-sdk to create a ttn client while the ttn is in my local desktop.

I follow the steps of GoLang Quick Start, in addition, I set the discovery address to my own. like this

	config := ttnsdk.NewCommunityConfig(sdkClientName)
	config.ClientVersion = "2.0.5"
	config.DiscoveryServerAddress = "discovery-serv:1900"

	config.TLSConfig = new(tls.Config)
	certBytes, err := ioutil.ReadFile(certPath)
	if err != nil {
		log.WithError(err).Fatal("my-amazing-app: could not read CA certificate file")
	}
	config.TLSConfig.RootCAs = x509.NewCertPool()
	if ok := config.TLSConfig.RootCAs.AppendCertsFromPEM(certBytes); !ok {
		log.Fatal("my-amazing-app: could not read CA certificates")
	}

	client := config.NewClient(appID, appAccessKey)
	defer client.Close()

I can get a DeviceManger object, but when I try to List my devices of my app, it crashed with a Token not found or expired error. And it turns out that the error happend when it run to ExchangeAppKeyForToken() of go-account-lib, it makes a post request to /api/v2/applications/token.

I thought it might be that I don’t have an account server ID, and I requested one, but I was wrong.

Is local ttn is not allowed or anything else ?

Can you help me? @htdvisser

I’m afraid not. Support for local or private installations is not done by the core team. If anyone in the community can help out here, that’s great, otherwise you may be interested in (commercial) support from The Things Industries or any other TTN partner.

1 Like