getTempTokenDBID method

Future<String> getTempTokenDBID({
  1. required String dbid,
  2. String? userAgent,
})

Get a temporary token for a dbid

Use this endpoint to get a temporary authorization token, scoped to either an app or a table. You can then use this token to make other API calls (see authorization). This token expires in 5 minutes.

Implementation

Future<String> getTempTokenDBID({
  required String dbid, String? userAgent
}) async {

  Map<String, String> headers = {
    'Content-Type': 'application/json; charset=UTF-8',
    'Accept': 'application/json',
    "QB-Realm-Hostname": qBRealmHostname,
    "QB-App-Token": qBAppToken,
    "User-Agent": userAgent?? ""

  };

  Uri endpoint = Uri.https(
      baseUrl, "v1/auth/temporary/$dbid");

  //print (endpoint.toString());

  var response = await
  http.get(endpoint,  headers: headers);

  if (response.statusCode >= 400) {
    throw ApiException(response.statusCode, response.body);
  }
  else if (response.statusCode == 200) {
    return jsonDecode(response.body)["temporaryAuthorization"];
  }
  else {
    throw ApiException(response.statusCode, response.body);
  }
}