Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Create System API key via API

    Scheduled Pinned Locked Moved Support
    2 Posts 2 Posters 19 Views
    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.
    • I Offline
      ivan.magdolen_6846
      last edited by

      Hello,

      is there a way how to create API key (key type = System with all permissions) via API or somehow automatically ?
      I found following native API:
      ApiKeys_CreateOrUpdateApiKey

      f952f901-1684-47d8-9e2c-fc9115f4e934-image.png

      but when I tried to use this code (powershell):
      $conf = '<Inedo.ProGet.ApiKeys.ApiKey Assembly="ProGetCoreEx"><Properties AllowPackagePromotionApi="False" AllowRepackagingApi="False" AllowFeedManagementApi="False" AllowWebhooksApi="True"
      AllowConnectorHealthApi="True" AllowFeedsApi="True" AllowDockerBlobReaderApi="False" AllowSbomApi="True" AllowSbomUpload="True" UseApiKeyTasks="False" AllowNativeApi="True"
      DoNotLogRequest="True" DoNotLogResponse="True" /></Inedo.ProGet.ApiKeys.ApiKey>'
      $URL = "http://<myservername>/api/json/ApiKeys_CreateOrUpdateApiKey"
      $body = @{
      ApiKey_Text = "<my new API key>";
      ApiKey_Configuration = $conf;
      ApiKey_Name = "TestKeyName";
      #ApiKey_Id = "2";
      ApiKey_Description = "Description API Key"
      }
      Invoke-RestMethod -Method Post -Uri $URL -Body ($body | ConvertTo-Json) -ContentType "application/json"

      I got following error
      30ac21b1-967e-4391-afc9-280c7da0e019-image.png

      so it seems I need some API key to create another API key.
      The purpose of this is to fully automate installation and configuration of Proget and avoid manual configuration of API key in Proget GUI.
      Once API key is created I would like to use that API for configuration of Feeds and Connectors.
      Thank you for your response.

      Kind regards
      Ivan Magdolen

      atrippA 1 Reply Last reply Reply Quote 0
      • atrippA Offline
        atripp inedo-engineer @ivan.magdolen_6846
        last edited by

        Hi @ivan-magdolen_6846,

        It looks like you're on the right track with finding the XML for that key.

        Since you're automating the installation, and already have DBO access to the ProGet database, I would suggest just directly adding it to the database using that stored procedure. You can also add/edit some values (like license key) if you want to the Configuration table.

        Alternatively I guess you could try Admin:Admin as the API key, since that account will be created by default. I'm not sure if it will work with the native API however.

        Best,
        Alana

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post
        Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation