admin管理员组

文章数量:1390471

I m trying to generate a token to then log in from python with the token. I have a terminal open and running on a user license. I really just want the token so that I dont have to have the terminal open. With terminal open all my python code runs fine. I found this code to generate a token on the blpapi github:

.py

I struggle to make this work though. I ran this with host 8194 and various options for auth but always get an error like this:

Connecting to localhost:8194 Failed to generate token: CID: {[ valueType=AUTOGEN classId=0 value=1 ]} RequestId: 16883008-3d96-b28f-0100-4a30a8c00600 TokenGenerationFailure = { reason = { source = "16883008-3d96-b28f-0100-4a30a8c00600" category = "NO_AUTH" errorCode = 12 description = "User not in emrs userid=U-DOM1\N20914 firm=74942" subcategory = "INVALID_USER" } }

How can I generate a token?

EDIT

The suggestion that you always have to be logged into the terminal is not accurate. I can do the following:

  1. Log into Terminal and test that my api based program downloads data - this works.
  2. Log out of terminal and rerun my program - still works.
  3. restart computer and rerun my program WITHOUT relogging into terminal - still works.
  4. I log into my bloomberg IOS app, rerun my program WITHOUT relogging into the terminal - still works (this is particularly strange as entering the IOS app doesnt close the terminal but forces you to reeneter your password.)

To me this means there is some token saved somewhere. That is also suggested by the link I shared above. It seems this token expires after a certain time (for instance I last logged into terminal Friday lunch time and Monday morning the program would not work without relogging into terminal).

How do I explicitly get to the token directly?

I m trying to generate a token to then log in from python with the token. I have a terminal open and running on a user license. I really just want the token so that I dont have to have the terminal open. With terminal open all my python code runs fine. I found this code to generate a token on the blpapi github:

https://github/msitt/blpapi-python/blob/master/examples/demoapps/GenerateTokenExample.py

I struggle to make this work though. I ran this with host 8194 and various options for auth but always get an error like this:

Connecting to localhost:8194 Failed to generate token: CID: {[ valueType=AUTOGEN classId=0 value=1 ]} RequestId: 16883008-3d96-b28f-0100-4a30a8c00600 TokenGenerationFailure = { reason = { source = "16883008-3d96-b28f-0100-4a30a8c00600" category = "NO_AUTH" errorCode = 12 description = "User not in emrs userid=U-DOM1\N20914 firm=74942" subcategory = "INVALID_USER" } }

How can I generate a token?

EDIT

The suggestion that you always have to be logged into the terminal is not accurate. I can do the following:

  1. Log into Terminal and test that my api based program downloads data - this works.
  2. Log out of terminal and rerun my program - still works.
  3. restart computer and rerun my program WITHOUT relogging into terminal - still works.
  4. I log into my bloomberg IOS app, rerun my program WITHOUT relogging into the terminal - still works (this is particularly strange as entering the IOS app doesnt close the terminal but forces you to reeneter your password.)

To me this means there is some token saved somewhere. That is also suggested by the link I shared above. It seems this token expires after a certain time (for instance I last logged into terminal Friday lunch time and Monday morning the program would not work without relogging into terminal).

How do I explicitly get to the token directly?

Share Improve this question edited Mar 17 at 7:42 nik asked Mar 14 at 10:47 niknik 1,7962 gold badges17 silver badges38 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

You cannot login without a terminal, unless you have a separate data license.

Otherwise, you need to be logged into the terminal. You don't seem to have a separate license, which is why you get the response that you are an invalid user and have no authorization.

There are three possibilities:

  • If you think you have a data license, reach out to Bloomberg (the help desk will only be of marginal help, but they can let you know who you should reach out to within data sales). They will get you the required credentials.

  • If you don't have a separate license, you need to be logged into the terminal while you use the API. You can send yourself an IB with {Docs 2076084} in it (the {} will create a direct link) for the license details. Clicking on the link opens the Desktop API (Excel Add-In) Guidelines document. Alternatively, just search for the document 2076084.

  • You don't have a license but would like to pay for access to the API without a terminal. Again, ask the help desk (or your representative who pops up when you look at the main screen of your terminal) to get the data sales team to reach out to you and discuss possible solutions and offerings with you.

Edit

The API connection is not terminated right away unless you do so manually yourself (you should be able to do so by typing stop api in your windows search icon and following the instructions). It think it should also log you out your windows terminal connection if you use terminal mode on an ipad (not just a simple login). Otherwise, try a different computer (if you are BBA), that should also stop the connection on your current machine where Python is running.

Bottom line is that you need the terminal to establish a connection and there is no way around it unless you have some data license. Otherwise, once the connection is broken (it times out after some time, usually several hours), you cannot use the API anymore. The system is purposely designed so that you cannot use it with just a token (that's why it's called desktop API).

Otherwise you could simply use it from anywhere on any machine you wish. This feature is not part of a desktop license and a separate offering.

The core user Guide on https://www.bloomberg/professional/support/api-library/ states in 6.4. DESKTOP API

The Desktop API is used when the end-user application resides on the same machine as the installed Bloomberg Professional service and connects to the local Bloomberg Communications Server (BBComm) to obtain data from the Bloomberg Data Center.

Once the local connection is broken, you need to login on your terminal again to reestablish a connection with the API.

GENERATETOKEN allows you to requests a token string for the specified application and/or user entered in EMRS, which is then used for identification. This is also clearly described in the user guide(s) I referenced above.

EMRS (see your response and the user guides) is the Entitlement Management and Reporting Service and is part of BPIPE (according to the docs, it's also used in other systems like server API plus, not the standard SAPI though) and permissions data to entitled users.

If you don't believe me, ask your sales rep or the help desk, which is anyhow the preferred thing to do when it comes to Bloomberg solutions.

The Bloomberg Terminal, when fired up and logged in offers up something called teh Desktop API (DAPI), or more accurately, the BLP API. This API is the "real-time" API and is available across many of Bloomberg's products, including Server API (SAPI), B-PIPE, EMSX, MARS, etc. The BLP API offers up real-time access to content/data, it's the "I want it now" interface, whereas a product like Data License is the "I'm happy to get it sometime in the future (eg, 5 minutes)". Back to the Desktop API, aligned to the Bloomberg Terminal. When you first login, it creates a "Token". The Token enables DAPI and allows you to make requests. There are a number of actions that can invalidate the Token. Logging out is not one of them, which is why you can continue to use DAPI when you logout. However, the two major events that cause the Token to be invalidated are; timeout, and, logging in from somewhere else. The timeout use to be several days and in those days you could have run it across the weekend, then it went down to a day, and now it's probably even shorter. There is no programmatic access into manipulating the Token. You have to remember that the Bloomberg Terminal (and the data) is licensed on the basis of eyes-only access, and that the token lifetime being shortened reinforces the fact that the API is not an application feed, it's there to support using the Bloomberg Terminal. The Excel Bloomberg Addin also uses this API (DAPI/BLP API), so if you login somewhere else, or let the token timeout, your Excel will also cease functioning.

If you need to run autonomously, then you possibly need to consider Server API (that can run client mode, or client/server mode), or possibly B-PIPE, an enterprise offering that has fewer restrictions.

The errors you are getting are associated with another Token, that of the entitlement system (EMRS), whereby identity management can be performed by establishing tokens. Unless you have B-PIPE that's pretty fruitless. The entitlement system on Server API (SAPI) is called SAPE but is based on EMRS.

Update: I should have said, that the only sort of "auth" on a Bloomberg Terminal (and DAPI) is biometrics. Your use case sounds incompatible with Terminal/DAPI but may be a good fit for SAPI and that need not cost your anisation a lot.

本文标签: Bloomberg API (blpapi)failing to generate access api tokenStack Overflow