Custom AuthID with local server

Hi,

Is it possible to generate and use custom AuthID instead of auto generated by Blynk App ? Every time I use new mobile, i need to change my code for AuthID, is there any way so that I can generate my AuthID and put some logic in sketch to use the same without changing it every time.

Also is it possible with Local server ?

Thanks,
Krunal

Hello. Could you please explain what do you mean by AuthID?

I guess AuthID = Auth Token
:sunglasses:

Yes, I mean Auth Token which is generated from Blynk app and we hard code in our sketch.

Thanks,
Krunal

What is mobile in that case?

You can share or clone the project to other devices.

If AuthID means Bkynk token then you are wrong. Any number of Smartphones (mobiles) can access hardware with the same token in the app.

I don’t think any of us really understand what your problem is. Please provide more details.

Hi,

Let me try to explain what I trying to say. Below are simple steps that we follow to run simple project using Blynk.

  1. Download Blynk app and create new project where I will get Blynk token when I check the settings.
  2. In Arduino sketch I use same Blynk token in my sketch and load to Arduino.

Hence if both has same Blynk token it will work.
Based on some of the reply from previous posts, we can access multiple hardware with same token.We can share app to other mobiles which will have same token so that multiple mobiles can control same hardware. This is what I understand and agreed with.

Hence my question is, in case of new set of hardware and mobile app it will be a new Blynk token which needs to be hard coded into Arduino sketch. Hence if I need to provide similar project to different people, I need to hardcode Blynk token and wifi credentials in Arduino sketch which may not be feasible. Hence is there any way that this Token can be generated using program and wifi details are asked to user instead of hard coded in sketch.

Thanks,
Krunal

From what I can see you just need to use Blynk’s cloning facility and don’t use hard coded tokens in the sketch. There are ways for end users to insert their own tokens in the hardware as allocated by the cloning procedure. The best known system is WiFi Manager but I would say there are now better ways.

Hi Costas,

What is cloning facility ? Is that free for user ? Could you please provide more details around that ?

Thanks,
Krunal

If you press the nut icon when you stop a project you have a screen relating to sharing and cloning the project.

First comes sharing and it “costs” 1000 Energy units to share a project. Click the Generate Link and it will create a QR code and url for the project to share it with other users.

Scroll further down and there is a cloning option. Again click the Generate Link etc.
There is no cost for the project creator but any user that wants to use a copy of the project requires the amount of Energy you used in the project.

If you are very creative you can keep many projects below the 2000 units given to all users for free i.e. don’t use 2 LED’s when you can now change the colour of LED’s and make comprehensive use of the Terminal as you can issue thousands of commands with it rather than using lots of different widgets.

With cloning you need to include one of the many tools available to get a new token into the hardware unlike sharing which uses the same token for each sharer.

Thanks Costas for explanation.

I tried cloning option and I was able to share my project with another user. However, when I see Token from new user it is different from my initial mobile. I guess that is the difference between clone and sharing.

In this case, I will need to create new sketch with token code hard coded. [quote=“Costas, post:11, topic:8994”]
With cloning you need to include one of the many tools available to get a new token into the hardware
[/quote]
Could you please help with how to incude tool to get new token into hardware ? so that it do not require hard coding of token in sketch.

Thanks,
Krunal

The best known tool, as per my earlier post is WiFi Manager, built by a Blynker called @tzapulica

Enter “github wifimanager” in Google and you are good to go. Look at the example with “parameters” that I believe already includes a Blynk token example.

If you have reasonable coding skills the best way is Blynk itself and this is one of many threads on the site that covers ways to do it Blynk App, to set esp8266-12e (Auth,ssid, and pass)

Thanks Costas, I visited wifimanager and it looks awesome. It solves the issue of hard coding wifi ssid and password in sketch.

However, I still see problem with Token. I am not sure if it allows to set token as well. Hence it still requires token to be hard coded on sketch.

I also tried HTTP API just to control led. I used same token code in API and sketch which was generated from Blynk app and it works great. I tried to change only one character of the token in both API and sketch but when I tried to call API it says invalid token.

Thanks,
Krunal

You skimmed too quickly through WiFI Manager, it has everything you need and more.

Specifically https://github.com/tzapu/WiFiManager/blob/master/examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino

I think this thread could help me out with my issue.
In my setup I have a local blynk server supposedly running on a raspberry pi that has an ip (given by dhcp?) which I have to hard code in the sketch and indicate in the app when I connect. It is clear to me that using WiFimanager I can change SSID, password, and even the token (with additional “json” hassle) without hardcoding. However, my question is, is it possible to do the same with the the local server ip address (which may change with time) that my hardware is supposed to connect to, which I would normally indicate with blynk.config("token", "IP")?
This scenario would be actual if I was moving my hardware from one local server to another, for example.
Thanks!

@kost9 you can add as many parameters as you like to WiFiManager so IP wouldn’t be a problem.

One could also register with dyndns or similar services and code that into your sketches. You would than have to forward the 8442 port to the server. That way you always connect to the same IP (thus the Internet IP of your connection). If you Raspi changes IP, than you only have to change the port forward rule in your router.