Application: PERMISSION_DENIED


(Kanalizator) #1

Hello,
I am trying example from here:
https://www.thethingsnetwork.org/docs/applications/python/

My code:

# https://www.thethingsnetwork.org/docs/applications/python/

import time

import ttn

app_id = "martin_korinek_featherweather"
access_key = "secret"


def uplink_callback(msg, client):
    print("Received uplink from ", msg.dev_id)
    print(msg)


handler = ttn.HandlerClient(app_id, access_key)

# using mqtt client
mqtt_client = handler.data()
mqtt_client.set_uplink_callback(uplink_callback)
mqtt_client.connect()
time.sleep(60)
mqtt_client.close()

# using application manager client
app_client = handler.application()
my_app = app_client.get()
print(my_app)
my_devices = app_client.devices()
print(my_devices)

My setup:

C:\Users\martin>python -m pip list
Package                  Version
------------------------ -------
Events                   0.3
googleapis-common-protos 1.5.5
grpcio                   1.17.1
paho-mqtt                1.4.0
pip                      18.1
protobuf                 3.6.1
setuptools               40.6.3
six                      1.12.0
ttn                      2.1.4

Some packets are received ok, some with error:

C:\Users\martin\AppData\Local\Programs\Python\Python37-32\python.exe "C:\Program Files\JetBrains\PyCharm 2018.2\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 1965 --file C:/Users/martin/Documents/_projekty/lora/ttn_example/main.py
pydev debugger: process 13164 is connecting

Connected to pydev debugger (build 183.4886.43)
Received uplink from  feather32u4
MSG(app_id='martin_korinek_featherweather', dev_id='feather32u4', hardware_serial='9876B6000010FA08', port=1, counter=989, payload_raw='CWANSA==', payload_fields=MSG(celcius=24, humid=34), metadata=MSG(time='2019-01-04T16:05:51.847562816Z', frequency=867.7, modulation='LORA', data_rate='SF12BW125', airtime=1318912000, coding_rate='4/5', gateways=[MSG(gtw_id='cesgw5', gtw_trusted=True, timestamp=159914692, time='2019-01-04T16:05:51.791239Z', channel=6, rssi=-119, snr=-13.5, rf_chain=0, latitude=50.079052, longitude=14.393415, altitude=332)]))
Traceback (most recent call last):
  File "C:\Users\martin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ttn\application.py", line 59, in get
    app = self.client.GetApplication(req, TIME_OUT, meta)
  File "C:\Users\martin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\grpc\_channel.py", line 547, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "C:\Users\martin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\grpc\_channel.py", line 466, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
	status = StatusCode.PERMISSION_DENIED
	details = "permission denied: No "settings" rights to Application "martin_korinek_featherweather""
	debug_error_string = "{"created":"@1546617986.674000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1036,"grpc_message":"permission denied: No "settings" rights to Application "martin_korinek_featherweather"","grpc_status":7}"
>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2018.2\helpers\pydev\pydevd.py", line 1741, in <module>
    main()
  File "C:\Program Files\JetBrains\PyCharm 2018.2\helpers\pydev\pydevd.py", line 1735, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm 2018.2\helpers\pydev\pydevd.py", line 1135, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2018.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/martin/Documents/_projekty/lora/ttn_example/main.py", line 27, in <module>
    my_app = app_client.get()
  File "C:\Users\martin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ttn\application.py", line 64, in get
    " application: {}".format(err.code().name))
RuntimeError: ('Error while getting the', ' application: PERMISSION_DENIED')

Can someone please advice me what is wrong?
Thanks