[Python] python script to generate a token from Delinea Secure Server

Discussão em 'Python' iniciado por Stack, Maio 7, 2025.

  1. Stack

    Stack Membro Participativo

    I need to generate a token but can't seem to make it work.

    auth_details = {
    "usernname" : "fakeuser",
    "password" : "fakepassword",
    "grant_type" : "password",
    }

    uri = "https://secretserver.fakedomain.com/oauth2/token"

    headers = { 'Accept': "application/json",
    'Content-Type': "x-www-form-urlencoded",
    }

    response = requests.post(uri,data=auth_details,headers=headers)


    This result in Response 406. When I try to see the contents of response:

    print(response.text)

    <div id="header"><h1>Server Error</h1></div>
    <div id="content">
    <div class="content-container"><fieldset>
    <h2>406 - Client browser does not accept the MIME type of the requested page.</h2>
    <h3>The page you are looking for cannot be opened by your browser because it has a file name extension that your browser does not accept.</h3>
    </fieldset></div>
    </div>
    </body>


    I've tried changing the accept type to text/html, and I got a Response 200. But as expected , it's in html format and the details of the token is not there.

    </div>
    <div style="display:flex;flex-direction:column;margin-left:15px">
    <span style="font-size:17px">Please Wait</span>
    <span style="font-size:15px">Secret Server is loading</span>
    </div>



    Hoping someone can help me here. I've been searching around but can't find anything that worked. The link to Delinea docs is https://secretserver.infor.com/Rest...g/ApiToken/operation/ApiTokenService_GetToken.

    From this point I'm a loss of idea.

    Continue reading...

Compartilhe esta Página