• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Find API Tokens

    Scheduled Pinned Locked Moved Solved
    FOG Problems
    3
    4
    239
    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.
    • G
      Gulo
      last edited by

      Currently I am running FOG version 1.5.8

      I am trying to find a way to pull the global and user API tokens during/after the install of FOG.
      I have pulled the MYSQL username and password from /opt/fog/.fogsettings, and I queried the FOG database for both API keys, but the keys stored in the database are different than what the web interface.

      SELECT uAPIToken FROM users;
      SELECT settingValue FROM globalSettings WHERE settingKey='FOG_API_TOKEN';
      

      I tried digging through some of the code, and there were a couple of spots that was referring to BASE64 encoding, but even BASE64 decoding of the values in the DB did not work.

      Is there a way to find working API tokens through a scripting process?
      Querying a database, decoding, or even using Basic Auth and pulling them from the web interface?

      My use case for this is so that I can automatically create images and hosts from an external database. I am auto generating a FOG image using packer and vmware, and then assigning that image to hosts that are populated from another database that manages our machines. My goal is to fully automate the building, and deployment of FOG, and then capturing images, and auto adding hosts. The API tokens are my last major stumbling block.

      Tom ElliottT 1 Reply Last reply Reply Quote 0
      • Tom ElliottT
        Tom Elliott @Gulo
        last edited by

        @Gulo The tokens are base64 encoded.

        Stored in the DB as non-encoded.

        So if you take the string from the database and base64 encode it, that is your API token.

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        1 Reply Last reply Reply Quote 2
        • S
          Sebastian Roth Moderator
          last edited by

          @Gulo As far as I know you should be able the strings queried from the DB as is. Make sure the API is enabled.

          I suggest you compare the DB values with those you see in the web UI.

          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

          1 Reply Last reply Reply Quote 0
          • Tom ElliottT
            Tom Elliott @Gulo
            last edited by

            @Gulo The tokens are base64 encoded.

            Stored in the DB as non-encoded.

            So if you take the string from the database and base64 encode it, that is your API token.

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            1 Reply Last reply Reply Quote 2
            • [[undefined-on, G Gulo, ]]
            • G
              Gulo
              last edited by

              @Tom-Elliott

              I hadn’t thought to check in that direction. But you are correct.
              BASE64 encoding what is in the database matches what is displayed in the web UI.

              Thank you for the help.

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

              148

              Online

              12.1k

              Users

              17.3k

              Topics

              155.3k

              Posts
              Copyright © 2012-2024 FOG Project