<?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: Huawei eSight Open API login authentication fails in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499029#M61427</link>
    <description>&lt;P&gt;Thanks, but that didn't fix the problem. I added a PUT method to your curl.py and the connection can now be established.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Oct 2019 12:16:14 GMT</pubDate>
    <dc:creator>infrastructure_</dc:creator>
    <dc:date>2019-10-08T12:16:14Z</dc:date>
    <item>
      <title>Huawei eSight Open API login authentication fails</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499027#M61425</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt; I have to use "PUT" to login to my system and obtain a login token. Webtools curl command only supports GET, POST and DELETE as stated in the documentation. When I choose &lt;STRONG&gt;method=put&lt;/STRONG&gt; I don't get any errors in Splunk, will it work as intended? &lt;/P&gt;

&lt;P&gt;I need to authenticate via "userid" and "value" instead of user and password. I tried to put this information in the datafield like this, but it didn't work:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;| makeresults count=1&lt;BR /&gt;
 | eval data="{\"userid\":\"ApiUser\",\"value\":\"password\"}"&lt;BR /&gt;
 | curl method=put uri=&lt;A href="https://x.x.x.x:32102/rest/openapi/sm/session"&gt;https://x.x.x.x:32102/rest/openapi/sm/session&lt;/A&gt;&lt;BR /&gt;
 | table curl*&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;The developer @jkat54 suggested that the Huawei system might want the username and password as parameters and I might have to urlencode them so I tried these: &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;uri=&lt;A href="https://x.x.x.x:32102/rest/openapi/sm/session/?userid=ApiUser&amp;amp;value=password"&gt;https://x.x.x.x:32102/rest/openapi/sm/session/?userid=ApiUser&amp;amp;value=password&lt;/A&gt;&lt;BR /&gt;
uri=&lt;A href="https://x.x.x.x:32102/rest/openapi/sm/session/%3Fuserid%3DApiUser%26value%3Dpassword"&gt;https://x.x.x.x:32102/rest/openapi/sm/session/%3Fuserid%3DApiUser%26value%3Dpassword&lt;/A&gt;&lt;BR /&gt;
uri=&lt;A href="https://x.x.x.x:32102/rest/openapi/sm/session/?userid%3DApiUser&amp;amp;value%3Dpassword"&gt;https://x.x.x.x:32102/rest/openapi/sm/session/?userid%3DApiUser&amp;amp;value%3Dpassword&lt;/A&gt;&lt;BR /&gt;
uri=&lt;A href="https://x.x.x.x:32102/rest/openapi/sm/session/%3Fuserid=ApiUser%26value=password"&gt;https://x.x.x.x:32102/rest/openapi/sm/session/%3Fuserid=ApiUser%26value=password&lt;/A&gt;&lt;BR /&gt;
I also tried  uri=.../?xxx and uri=...?xxx&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;When I use &lt;STRONG&gt;Splunk and any variation of the curl command listed above&lt;/STRONG&gt; the logs on the Huawei system show "&lt;EM&gt;Open API request from third system, URL: /rest/openapi/sm/session, error message: Authentication failed.&lt;/EM&gt;" and it shows username as "&lt;EM&gt;Invalid User&lt;/EM&gt;".&lt;/P&gt;

&lt;P&gt;If I &lt;STRONG&gt;connect to the API via another method&lt;/STRONG&gt; the login succeeds. Whenever I input a wrong password or username, the chosen username will be displayed in the logs and the error message is "&lt;EM&gt;Failure reason: The user name does not match the password or the account does not exist.&lt;/EM&gt;"&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Therefore it's not a wrong username or password error when using the curl command.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Step 2:&lt;/STRONG&gt; After I obtain a session token with the above search (assuming it's working), I can use this token to query the API via executing additional curl commands. How would I do that in a Splunk search? &lt;/P&gt;

&lt;P&gt;This is an excerpt from the documentation of the systems API to gain an access token:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/*
 * Log in Example
 */
public class Login
{ 
    public static void main(String[] args) throws Exception 
    {  
      login();
    }

    public static void login() throws Exception
    {
        //set the URL and method
        final String openidURL = "/rest/openapi/sm/session";
        final String method = "PUT";
        //set parameters
        final List&amp;lt;BasicNameValuePair&amp;gt; parameters = new ArrayList&amp;lt;BasicNameValuePair&amp;gt;();
        parameters.add(new BasicNameValuePair("userid", GlobalVar.GLOBAL_USERNAME));
        parameters.add(new BasicNameValuePair("value", GlobalVar.GLOBAL_USERVALUE));
        parameters.add(new BasicNameValuePair("ipaddr", GlobalVar.GLOBAL_USERIP));
        //send the request
        final HttpResponse response = NewHttpsAccess.access(GlobalVar.GLOBAL_IP,
                GlobalVar.GLOBAL_PORT,
                openidURL,
                method,
                null,
                parameters);
        //get the result
        final String ret = NewHttpsAccess.getResult(response);
        System.out.println(ret);
        //resolve the result and get the openid
        final JSONObject jObject = JSONObject.fromObject(ret);
        if (null == jObject)
        {
            System.out.println("Login failed.");
            return;
        }
        if ("0".equals(String.valueOf(jObject.get("code"))))
        {
            final String openid = String.valueOf(jObject.get("data"));
            GlobalVar.globalOpenid = openid;
        }
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Oct 2019 11:39:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499027#M61425</guid>
      <dc:creator>infrastructure_</dc:creator>
      <dc:date>2019-10-08T11:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Huawei eSight Open API login authentication fails</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499028#M61426</link>
      <description>&lt;P&gt;Hey thanks for the awesome post!&lt;/P&gt;

&lt;P&gt;I have a code fix for you in version 1.2.5: &lt;A href="https://splunkbase.splunk.com/app/4146/"&gt;https://splunkbase.splunk.com/app/4146/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Here's where the code was buggy:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7791i93A4D33DE469D742/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;As always, thank you for your support and if you like my apps, please leave a review on splunkbase, share some karma, or if you're super impressed, write a review for me on linkedin.  Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 11:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499028#M61426</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-10-08T11:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Huawei eSight Open API login authentication fails</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499029#M61427</link>
      <description>&lt;P&gt;Thanks, but that didn't fix the problem. I added a PUT method to your curl.py and the connection can now be established.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 12:16:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499029#M61427</guid>
      <dc:creator>infrastructure_</dc:creator>
      <dc:date>2019-10-08T12:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Huawei eSight Open API login authentication fails</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499030#M61428</link>
      <description>&lt;P&gt;that was my next idea...&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 16:47:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499030#M61428</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-10-08T16:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Huawei eSight Open API login authentication fails</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499031#M61429</link>
      <description>&lt;P&gt;I just added it to the app via version 1.2.6  Please do enjoy.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 18:00:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Huawei-eSight-Open-API-login-authentication-fails/m-p/499031#M61429</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-10-08T18:00:14Z</dc:date>
    </item>
  </channel>
</rss>

