🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Read own API Key in UIFlow/micropython?

    UIFlow
    5
    11
    13.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • U
      utaani
      last edited by

      We have set up a number of M5 Stick Cs for remote IT education purposes. We have developed a cloud service for device management, and it is now possible to send a mac address (as a unique ID) from UIFlow to our cloud service using http. If we can upload the UIFlow API Key for each device at the same time as the macaddress, we think that we can distribute the m5f file to the managed M5 Stick C without having the students make notes.

      Is there a way to access the device's API Key from Block or micropython?

      1 Reply Last reply Reply Quote 0
      • R
        robalstona
        last edited by

        Try

        print(APIKEY)
        #or
        print(_APIKEY)
        

        Should work. On device boot in serial monitor was displayed all boot messages includes apikey.

        U 1 Reply Last reply Reply Quote 0
        • U
          utaani @robalstona
          last edited by

          @robalstona Thanks for reply.

          I tried the following code, but I get an error.

          from m5stack import *
          from m5ui import *
          from uiflow import *
          
          setScreenColor(0x111111)
          
          print(APIKEY)
          

          0_1630884807759_3f5e857e-8620-4937-b1db-9fd5be124cec-image.png

          "_APIKEY" also resulted in an error.

          Do I need to install any additional modules?

          1 Reply Last reply Reply Quote 0
          • IAMLIUBOI
            IAMLIUBO
            last edited by

            Try:

            import deviceCfg
            print("APIKEY: " + deviceCfg.get_apikey())
            

            But the APIKEY not fixed.I think you should use MAC addr for the devices:

            import machine
            import binascii
            mac_addr = binascii.hexlify(machine.unique_id()).decode('utf-8')
            
            U 1 Reply Last reply Reply Quote 0
            • U
              utaani @IAMLIUBO
              last edited by

              @iamliubo, Thanks for reply!

              By using this code, I was able to get the API Key:

              import deviceCfg
              akey=deviceCfg.get_apikey()
              

              BTW, the MAC address can be obtained with the following code:

              macaddr=wifiCfg.wlan_sta.config('mac')
              macaddr='{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}'.format(*macaddr)
              

              Thank you!

              1 Reply Last reply Reply Quote 2
              • L
                labixiaoxin8888
                last edited by

                Hello, how about accessing the device's API key from Blockly? Is it possible? I am using M5 Stack new Stamp Pico.

                ajb2k3A 1 Reply Last reply Reply Quote 0
                • ajb2k3A
                  ajb2k3 @labixiaoxin8888
                  last edited by

                  @labixiaoxin8888 No need as the API key is stuck on the front of the stamp.

                  If you install Thonny and run the terminal monitor, the API's for any device connected will be shown in the terminal for Micropython.

                  UIFlow, so easy an adult can learn it!
                  If I don't know it, be patient!
                  I've ether not learned it or am too drunk to remember it!
                  Author of the WIP UIFlow Handbook!
                  M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                  L 1 Reply Last reply Reply Quote 0
                  • L
                    labixiaoxin8888 @ajb2k3
                    last edited by

                    @ajb2k3 Alright, thank you!

                    1 Reply Last reply Reply Quote 0
                    • L
                      labixiaoxin8888
                      last edited by

                      @ajb2k3 Is it possible to print any output for UI flow remote control website?

                      1 Reply Last reply Reply Quote 0
                      • ajb2k3A
                        ajb2k3
                        last edited by

                        There is an experimental feature of Micropython called webRPEL

                        UIFlow, so easy an adult can learn it!
                        If I don't know it, be patient!
                        I've ether not learned it or am too drunk to remember it!
                        Author of the WIP UIFlow Handbook!
                        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                        L 1 Reply Last reply Reply Quote 0
                        • L
                          labixiaoxin8888 @ajb2k3
                          last edited by

                          @ajb2k3 Thanks!

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post