Guides
GsSession
GsSession
GsSession manages authentication for the GS Developer APIs. This class allows you to hold an authentication context to the developer APIs within a given process. You can hold a reference to multiple sessions within the same process.
OAuth
Authenticating with OAuth application credentials.
Note
Application credentials can be created through the Marquee Developer Site. OAuth is the recommended approach for Goldman Sachs clients.
Create and use a GsSession with OAuth application credentials:
from gs_quant.session import GsSession
client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_CLIENT_SECRET'
GsSession.use(client_id=client_id, client_secret=client_secret)
Replace the above clientid
and client_secret
with your own credentials.
Single-Sign-On
Where SSO is available, users can authenticate as follows:
from gs_quant.session import GsSession
GsSession.use()
Scopes
GS Developer scopes provide access to different capabilities within GS Quant. These scopes can be
requested through the Marquee Developer Site. Scopes are
linked to your registered application. You can create multiple applications with different scopes in
order to protect your processes. For example, your trading application may require the
execute_trades
scope, but you wouldn't need other applications which only read data to have these
elevated permissions. More information on the different scopes is available
here.
To initialize a session with the default set of scopes:
from gs_quant.session import GsSession
client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_CLIENT_SECRET'
scopes = GsSession.Scopes.get_default()
GsSession.use(client_id=client_id, client_secret=client_secret, scopes=scopes)
To initialize a session with the a specific set of scopes:
from gs_quant.session import GsSession
client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_CLIENT_SECRET'
scopes = [
GsSession.Scopes.MODIFY_FINANCIAL_DATA,
GsSession.Scopes.READ_FINANCIAL_DATA
]
GsSession.use(client_id=client_id, client_secret=client_secret, scopes=scopes)
Environments
Developers can access different environments using the provided constants. Production environments should be used for all GS Quant access except where testing workflows prior to deployment (e.g. testing trading integration).
from gs_quant.session import Environment
GsSession.use(environment_or_domain=Environment.QA, client_id=client_id, client_secret=client_secret, scopes=scopes)