Skip to main content

Passing a WLSToken to Gurobi environments

Awaiting user input

Comments

3 comments

  • Juan Orozco
    Gurobi Staff Gurobi Staff

    Hi, David!

    In Python you can also provide programmatically the WLS credentials, which can be found in the license file that you previously downloader from our Web License Manager, as follows:

    import os
    import gurobipy as gp
    from gurobipy import GRB

    GRB_HOME = os.environ.get("GUROBI_HOME")

    myenv = gp.Env(empty=True)
    #Info contained in the API key file.
    myenv.setParam("WLSAccessID", <myWLSAccessIDAsString>)
    myenv.setParam("WLSSecret", <myWLSSecretAsString>)
    myenv.setParam("LicenseID", <myLicenseIDAsInteger>)
    myenv.start()

    model = gp.read(f"{GRB_HOME}/examples/data/afiro.mps", env=myenv)
    model.optimize()
    model.dispose()
    myenv.dispose()

    Finally, it's worth noting you seem to be a commercial user. Remember that you request support by opening a ticket in our Help Center.

    0
  • David Bach
    First Comment
    First Question

    Hi Juan,

    thank you for the message! I can verify that using `WLSAccessID`, `WLSSecret`, and `LicenseID` works for me. Is it possible to only supply the `WLSToken` without the other parameters? I would like to separate the service requesting tokens from the service running the Gurobi optimizer for security reasons. I used the WLS credentials to request a token from `https://token.gurobi.com:443/` and want to pass this token to the Gurobi environment. 

    Thanks,

    David 

    0
  • Eli Towle
    Gurobi Staff Gurobi Staff

    Yes, this is still supported. Can you please make sure the Gurobi version specified in your POST request matches the version of Gurobi you're using to run your code? I could reproduce the error you described when passing a Gurobi 11.0.2 WLS token to Gurobi 11.0.1, and vice versa.

    0

Please sign in to leave a comment.