vshymanskyy / blynk-library-python

Blynk library for Python. Works with Python 2, Python 3, MicroPython.
https://blynk.io/
MIT License
286 stars 98 forks source link

Invalid Token RPi4b #62

Open domcio01 opened 2 years ago

domcio01 commented 2 years ago

Hi i have problem with connecting my raspi with blynk.cloud via python3 i get invalid token information all the time. For now im only trying to connect and see if device is online.

blynk1

import BlynkLib
BLYNK_AUTH = 'CEliuHR*************1AafR9G9__k'
blynk = BlynkLib.Blynk(BLYNK_AUTH, server='blynk-cloud.com', port=8080)

while True:
    blynk.run()

and i got blynk2

what i did :

pip install blynk-library-python

i also cloned this git and run

 sudo python3 setup.py

i also tried to install other python blynk libraries from git but i have the same problem

ebolisa commented 2 years ago

Why are you connecting to port 8080? This works for me on an ESP: https://community.blynk.cc/t/device-offline-micropython-new-blynk/58432/32?u=emilio and have you seen this? https://github.com/vshymanskyy/blynk-library-python/blob/master/examples/Edgent_Linux_RPi/main.py

ebolisa commented 2 years ago

Hi i have problem with connecting my raspi with blynk.cloud via python3 i get invalid token information all the time. For now im only trying to connect and see if device is online.

blynk1

import BlynkLib
BLYNK_AUTH = 'CEliuHR*************1AafR9G9__k'
blynk = BlynkLib.Blynk(BLYNK_AUTH, server='blynk-cloud.com', port=8080)

while True:
    blynk.run()

and i got blynk2

what i did :

pip install blynk-library-python

i also cloned this git and run

sudo python3 setup.py

i also tried to install other python blynk libraries from git but i have the same problem

Also, your're using an older lib version.

domcio01 commented 2 years ago

@ebolisa what i new version of lib 1.0.0? thanks that worked for ver 0.2.0 but not for 1.0.0

import BlynkLib
BLYNK_AUTH="token"
try:
#         blynk = BlynkLib.Blynk(BLYNK_AUTH, insecure=True)
        blynk = BlynkLib.Blynk(BLYNK_AUTH,
#        insecure=True,          # disable SSL/TLS
        server='blynk.cloud', # fra1.blynk.cloud or blynk.cloud
        port=80,                # set server port
        heartbeat=30,           # set heartbeat to 30 secs
        log=print              # use print function for debug logging
        )
except OSError as e:
    utime.sleep(3)
    restart_and_reconnect(e)
while True:
   blynk.run()
ragasjohn commented 2 years ago

Hello I have the same problem on a Pi Zero. I just copied the example

Invalied auth token

dulinux commented 2 years ago

Same thing here: "Invalid auth token".

pi@raspberrypi:~/bin/doorbell $ pip3 list | grep -i blynk
blynk-library-python             0.2.0

My script test file:

import BlynkLib

BLYNK_AUTH = "oC############################aN"  # OMITTED FOR GITHUB

# initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)

@blynk.VIRTUAL_WRITE("V0")
def v0_write_handler(value):
    print('Current v0 value: {}'.format(value))

while True:
    blynk.run()

Double checked and the auth tokin is identical to the device's info.

pi@raspberrypi:~/bin/doorbell $ python3 blynk_og.py

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ for Python v0.2.0 (Linux)

Invalid auth token
ebolisa commented 2 years ago

Try to use your local server (shown at the bottom rt in your dashboard) and not blynk.cloud. Also try the example shown above.

dulinux commented 2 years ago

My script test file:

blynk = BlynkLib.Blynk(BLYNK_AUTH)

Solved by manually specifying the server with:

 blynk = BlynkLib.Blynk(BLYNK_AUTH, server="blynk.cloud")
ebolisa commented 2 years ago

If you use a closer server to you, the connection will be a bit faster. In EU it’s fra1.blynk.com As shown in the test code above.