<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: get_global_setting returns api_key as &amp;quot;undefined&amp;quot; in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/527140#M9420</link>
    <description>&lt;P&gt;Interesting... this is on the read of the password in the custom search command after it has been configured? Are you running the search from the context of the weather example, or from the search and reporting app?&amp;nbsp;&lt;/P&gt;&lt;P&gt;One additional app that might help you debug issues with secret storage is &lt;A title="REST storage/passwords Manager for Splunk" href="https://splunkbase.splunk.com/app/4013/" target="_blank" rel="noopener"&gt;REST storage/passwords Manager for Splunk&lt;/A&gt;. This app is a great example of how to work with the storage/passwords endpoint and is useful for troubleshooting permissions mismatches between apps.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Oct 2020 16:51:33 GMT</pubDate>
    <dc:creator>thellmann</dc:creator>
    <dc:date>2020-10-29T16:51:33Z</dc:date>
    <item>
      <title>get_global_setting returns api_key as "undefined"</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/525804#M9416</link>
      <description>&lt;P&gt;Reposting this in the correct area of the forum.&lt;/P&gt;&lt;P&gt;I have made a Tech add on that polls an API. In order to perform requests against the API, an API key is required.&lt;/P&gt;&lt;P&gt;I have used the following as the example in order to get the URL and the API key for the request saved onto Splunk:&lt;BR /&gt;&lt;A href="https://github.com/splunk/Developer_Guidance_Setup_View_Example" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;https://github.com/splunk/Developer_Guidance_Setup_View_Example&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The setup page is working as expected from that example, and am able to correctly populate data with it. After that, when I look at the app specific conf files ( ie /opt/splunk/etc/apps/TA-eg/local/ta_eg_settings.conf)&lt;BR /&gt;&lt;BR /&gt;Then I see that the api_key is starred out, ie encrypted at rest:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[additional_parameters]
api_key = ********
eg_domain = &amp;lt;correct_plaintext_domain&amp;gt;
disabled = 0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following files are also present in&amp;nbsp;/opt/splunk/etc/apps/TA-eg/local/:&lt;BR /&gt;app.conf&lt;/P&gt;&lt;P&gt;inputs.conf&lt;/P&gt;&lt;P&gt;passwords.conf&lt;/P&gt;&lt;P&gt;However if I attempt to use the python helper function&amp;nbsp;&lt;STRONG&gt;get_global_setting(&lt;/STRONG&gt;&lt;I&gt;"api_key"&lt;/I&gt;&lt;STRONG&gt;)&amp;nbsp;&lt;/STRONG&gt;as defined in:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/AddonBuilder/3.0.2/UserGuide/PythonHelperFunctions" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;https://docs.splunk.com/Documentation/AddonBuilder/3.0.2/UserGuide/PythonHelperFunctions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Then it is always returning the string "undefined" as opposed to the correct API key that I added.&lt;/P&gt;&lt;P&gt;In&amp;nbsp;&lt;I&gt;&lt;SPAN&gt;TA-eg/bin/TA_eg_rh_settings.py&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/I&gt;I have also set encrypted = True for the correct field:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fields_additional_parameters = [
    field.RestField(
        'eg_domain',
        required=True,
        encrypted=False,
        default='',
        validator=validator.String(
            min_len=0, 
            max_len=8192, 
        )
    ), 
    field.RestField(
        'api_key',
        required=True,
        encrypted=True,
        default='',
        validator=validator.String(
            min_len=0, 
            max_len=8192, 
        )
    )
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;Please help me figure out how to get the correct output of this encrypted at rest API key using the Splunk helper functions.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-panel lia-panel-standard LabelsForMessage Chrome lia-component-message-view-widget-labels"&gt;&lt;DIV class="lia-decoration-border"&gt;&lt;DIV class="lia-decoration-border-top"&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Oct 2020 14:00:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/525804#M9416</guid>
      <dc:creator>KeaganJ</dc:creator>
      <dc:date>2020-10-21T14:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: get_global_setting returns api_key as "undefined"</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/525893#M9417</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225779"&gt;@KeaganJ&lt;/a&gt;&amp;nbsp;- let me refer you to the weather_app_example in this repo:&amp;nbsp;&lt;A href="https://github.com/splunk/splunk-app-examples" target="_blank"&gt;https://github.com/splunk/splunk-app-examples&lt;/A&gt;&amp;nbsp;(make sure to perform setup with make before running the specific example)&amp;nbsp;&lt;/P&gt;&lt;P&gt;A specific example of retrieving a credential from the storage/passwords endpoint is right here:&amp;nbsp;&lt;A href="https://github.com/splunk/splunk-app-examples/blob/master/case_studies/weather_app_example/bin/weather.py#L30" target="_blank"&gt;https://github.com/splunk/splunk-app-examples/blob/master/case_studies/weather_app_example/bin/weather.py#L30&lt;/A&gt;&lt;/P&gt;&lt;P&gt;To actually answer your question, I suspect that get_global_setting is not able to retrieve information stored via the storage/passwords endpoint&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2020 19:14:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/525893#M9417</guid>
      <dc:creator>thellmann</dc:creator>
      <dc:date>2020-10-21T19:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: get_global_setting returns api_key as "undefined"</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/526226#M9418</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/182467"&gt;@thellmann&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for pointing me to that weather app example. Though using that method in the link you sent me using:&lt;BR /&gt;`&lt;SPAN class="pl-s1"&gt;secrets&lt;/SPAN&gt; &lt;SPAN class="pl-c1"&gt;=&lt;/SPAN&gt; &lt;SPAN class="pl-s1"&gt;search_command&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN class="pl-s1"&gt;service&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN class="pl-s1"&gt;storage_passwords`&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="pl-s1"&gt;Does not work and every time I try to run the above command I get that `search_command&lt;SPAN&gt;.&lt;/SPAN&gt;service` returns a None type variable.&lt;BR /&gt;Diving deeper down into the code I track down that the `&lt;/SPAN&gt;&lt;SPAN&gt;def&lt;/SPAN&gt; &lt;SPAN&gt;service&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;self&lt;/SPAN&gt;&lt;SPAN&gt;):` function in `splunklib/searchcommands/search_command.py` is returning None because no metadata can be found.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am not sure how or why the metadata is not getting created correctly here?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2020 13:12:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/526226#M9418</guid>
      <dc:creator>KeaganJ</dc:creator>
      <dc:date>2020-10-23T13:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: get_global_setting returns api_key as "undefined"</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/526791#M9419</link>
      <description>&lt;P&gt;I figured out how to do it using the helper function.&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;`helper.service.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;storage_passwords` gives you the correct data that you then just need to parse correctly.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 28 Oct 2020 09:15:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/526791#M9419</guid>
      <dc:creator>KeaganJ</dc:creator>
      <dc:date>2020-10-28T09:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: get_global_setting returns api_key as "undefined"</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/527140#M9420</link>
      <description>&lt;P&gt;Interesting... this is on the read of the password in the custom search command after it has been configured? Are you running the search from the context of the weather example, or from the search and reporting app?&amp;nbsp;&lt;/P&gt;&lt;P&gt;One additional app that might help you debug issues with secret storage is &lt;A title="REST storage/passwords Manager for Splunk" href="https://splunkbase.splunk.com/app/4013/" target="_blank" rel="noopener"&gt;REST storage/passwords Manager for Splunk&lt;/A&gt;. This app is a great example of how to work with the storage/passwords endpoint and is useful for troubleshooting permissions mismatches between apps.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 16:51:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/get-global-setting-returns-api-key-as-quot-undefined-quot/m-p/527140#M9420</guid>
      <dc:creator>thellmann</dc:creator>
      <dc:date>2020-10-29T16:51:33Z</dc:date>
    </item>
  </channel>
</rss>

