teal-finance / quidart

A requests library for the Quid json web tokens server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quidart

A requests library for the Quid json web tokens server

Usage

Initialize:

import 'package:quidart/quidart.dart';

const quidUri = "http://localhost:8082";
const serverUri = "http://127.0.0.1:5000";
final requests = QuidRequests(
    baseUri: serverUri,
    quidUri: quidUri,
    namespace: "demo",
  );

Login and get a refresh and access token:

import 'package:quidart/src/exceptions.dart';

try {
    await requests.login(
        username: "demouser",
        password: "demouser",
    );
} on QuidException catch (e) {
    if (e.unauthorized) {
        // the login has failed
    }
} catch (e) {
    rethrow;
}

Make a get request:

final uri = "https://myserver.org/path";
final data = await requests.get<Map<String, dynamic>>(uri);

Make a post request:

final data = await requests.post<Map<String, dynamic>>(uri, <Map<String,dynamic>{"foo": "bar"}>);

About

A requests library for the Quid json web tokens server

License:MIT License


Languages

Language:Dart 100.0%