Thrift Client API (deprecated)¶
DataHub allows developers to connect client devices to datahub, create and delete accounts, and manipulate data on a user’s behalf.
Introduction to DataHub API Applications¶
DataHub API applications allow...
- end users to authorize an application to view and edit their data
- developers to view and edit data in authorized DataHub accounts
For example, a user,
grad_student has a datahub account. In this case, they want to authorize the
living_lab app to view and edit data in their
Navigate to developer/apps in your DataHub installation to create a new app.
End users must authorize your application by visiting permissions/apps/allow_access/APP_ID/REPO_NAME in their browser
Note: Make sure not to commit the App Name or App ID in any public repositories!
Generating Native Code¶
DataHub uses Apache Thrift to generate native code for your datahub client. You will need to do this before connecting to user accounts. You can generate native code using the commands below.
C++ Sample Code¶
# add credentials to SampleClient.cpp
Java Sample Code¶
# add credentials to SampleClient.java and SampleAccount.java
Python Sample Code¶
mv gen-py gen_py
# addCredentials to SampleClient.py and SampleAccount.py
Go Sample Code¶
go run SampleClient.go
SampleClient.htmlin a browser
Objective-C Sample Code¶
# add credentials to main.m
- not: when integrating thrift, in Build Settings:
- Always Search User Path:
- Framework Search Paths: add
Connecting with the Application API¶
It is possible to connect to a user’s account (without using their password) after they have authorized an application.
In order to follow these steps, you will have needed to create an application, which your end user(s) will need to authorize. See Introduction to DataHub API Applications.
See the src/examples/language/SampleAccount.*ext* for examples.
Connecting with a username & password¶
It is possible to connect to a user’s account without using an application. In this case, you will need their username and password.
Connections made using a username and password are unable to create or delete accounts.
See the src/examples/language/SampleClient.*ext* for examples.