Login user using browser javascript

I am building a website to login Blynk server using user email and password but kind of stuck. I am trying the blynk javascript library (https://github.com/vshymanskyy/blynk-library-js) and modify the library to support user login and load user profile with list of projects and devices.

When I tried to send message from browser with format [LOGIN email hashed_password], it failed and following log is found on blink server:

15:54:08.297 TRACE- HTTPS connection detected.
15:54:08.297 TRACE- Mapping from /websockets to /websockets
15:54:08.297 TRACE- In http and websocket unificator handler.
15:54:08.297 TRACE- Initialized secured hardware websocket pipeline. [WSIdleStateHandler, SslHandler#0, HttpsServerCodec, HttpsServerKeepAlive, HttpsObjectAggregator, WSChannelState, io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandshakeHandler, io.netty.handler.codec.http.websocketx.Utf8FrameValidator, WSWebSocketServerProtocolHandler, WSWebSocket, WSMessageDecoder, WSSocketWrapper, WSMessageEncoder, WSLogin, WSNotLogged, DefaultChannelPipeline$TailContext#0]
15:54:08.325 TRACE- Incoming LoginMessage{id=1, command=Login, body=‘xxx@mail.comY1wDUPw8ZpQRP/hEm3oMlwnlr+TqKG0zpEwCf4aE0gQ=’}
15:54:08.325 DEBUG- HardwareLogic token is invalid. Token ‘xxx@mail.comY1wDUPw8ZpQRP/hEm3oMlwnlr+TqKG0zpEwCf4aE0gQ=’, ‘/116.102.140.185:52116’

When logging from mobile app, it’s ok using same hashed password:

15:55:32.741 TRACE- Blynk protocol connection detected.
15:28:02.298 TRACE- Incoming LoginMessage{id=1, command=Login, body=‘xxx@gmail.comY1wDUPw8ZpQRP/hEm3oMlwnlr+TqKG0zpEwCf4aE0gQ=Android2.26.7Blynk’}
15:28:02.298 DEBUG- Re registering app channel. [id: 0x015c1488, L:/10.148.0.2:9443 - R:/116.102.140.185:33886]
15:28:02.299 INFO - xxx@gmail.com Blynk-app (android-22607) joined.
15:28:02.350 TRACE- Incoming id=2, command=LoadProfile, body=’’
15:28:02.351 TRACE- Incoming id=3, command=GetEnergy, body=’’
15:28:02.443 TRACE- Incoming id=4, command=AddPushToken, body=‘142684875761a841f8ae711f8dfLIQy-FYXpU:APA91bGZmrIgaL3y7BfviiPlV8gwSMRtquN9YP3otdFLp9TBpRtNPzqPwarff04N4uZl-BPu0J7Twlo-4Z8buSaIp6fVfPh-g0UCE_JAu1TdGMyAR9ZqYDl28KgcsZRNNabO-plmicfojQ8tZTiCHvSX4n0aKYsaUQ’
15:28:02.444 TRACE- Incoming id=5, command=AppSync, body=‘1426848757’

Can anyone give me a hint how to write javascript to login and load devices from browser? Thanks

Can anyone help me on this? Let me rephrase the whole story so it can be easier to understand what I am trying to achieve:

I saw that Blynk is great for backend server. But coding and uploading code to device in Arduino are slow and requires programming skill so I am creating a web page for user to do some block programming without knowing how to write code based on google blockly (https://developers.google.com/blockly/)

So what I need in my web app is to allow user to create or login account on my local Blynk server, create or load all devices and select a device to send code (using any internal virtual pin). The device will run a micropython firmware and listen to that virtual pin and download the code when receives update from server.

I am stuck at talking to Blynk server from web browser. I try to use the blynk javascript library to login a device with its token but cannot login a user and load all projects/devices.

Appreciate if anyone can give me a direction on this. By achieveing this, our open source community user and kids will be easier to code and use Blynk I think.

Always best to search before asking… This was just posted a few days ago :stuck_out_tongue_winking_eye:

Thanks. The app looks great but it’s not what I planned to do. I saw few similar apps but they just generate the code and you still need to install arduino and copy the code and compile and upload to your device via usb cable.

Using a web page without installing anything, just making code using blocks and sending the code wirelessly without compiling and cable will be great for any beginner. Actually user can create account and device in Blynk app, and copy the device token into the web app to upload code but it’s even better if user can login the web using same Blynk account, see all his devices and select a device to upload without worrying about its long generated token.

I still hope someone has any information about how to login an user. I tried to connect to server using websocket, sent a message with format “LOGIN email pass” but the server always checks the given info as a device token so it’s invalid.

I noticed that everytime Blynk app talks to server, there will be a line log below:

15:55:32.741 TRACE- Blynk protocol connection detected.

I did not see this log if a device logins using its token.

Well, I am just a user not a developer… but I do understand that while the library and even local server is open source, the App is NOT… so it is still a requirement for user account creation and Blynk use…

Tokens are also a requirement for device login… but I seem to recall something posted here about changes to that as well…?

Blynk is apparently working on a desktop/web page? solution… time will tell what that entails.

1 Like

My software is All in one version. you don’t need download arduino IDE or blynk-library.
what you need do ,is ,download the package ,unzip it! Enjoy it.
your idea is good , but my ability is limited.

@hznupeter Your app is excellent. We will introduce that to your community if they are using Arduino.

Dear @hznupeter what software do you mentioned?

@mikekgr See the link I posted above

1 Like

HERE

1 Like