studip

Creator: coderz1093

Last updated:

0 purchases

studip Image
studip Images

Languages

Categories

Add to Cart

Description:

studip

Stud.IP #



A library which provides simple access to Stud.IP's RestAPI services using
OAuth 1 authentication for Dart.
Usage #
Add to pubspec.yaml:
dependencies:
studip: ^2.1.3
copied to clipboard
A simple usage example:
import 'dart:convert';
import 'dart:io';

import 'package:studip/studip.dart' as studip;

void main() {
// Initialize client
final client = studip.StudIPClient(
'https://studip.uni-passau.de/studip/dispatch.php/api',
'CONSUMER_KEY',
'CONSUMER_SECRET',
apiBaseUrl: 'https://studip.uni-passau.de/studip/api.php/');
client.getAuthorizationUrl('example://oauth_callback').then((String url) {
// Get verifier by calling the returned link and approve access
print('Open URL in browser: $url');
final uri = stdin.readLineSync()!;

// Retrieve permanent token
final verifier = Uri.parse(uri).queryParameters['oauth_verifier'] ?? '';
return client.retrieveAccessToken(verifier);
}).then((void v) {
// Example call
return client.apiGetJson('user');
}).then((dynamic decoded) {
// Example parsing of response
print(decoded['name']['formatted']);
});
}
copied to clipboard
Additional compatibilities #
This library features additional compatibility for the flutter_web_auth_2 library.
You can use both libraries together like this:
import 'dart:convert';
import 'dart:io';

import 'package:flutter_web_auth_2/flutter_web_auth_2.dart';
import 'package:studip/studip.dart' as studip;

void main() {
// Initialize client
final client = studip.StudIPClient(
'https://studip.uni-passau.de/studip/dispatch.php/api',
'CONSUMER_KEY',
'CONSUMER_SECRET',
apiBaseUrl: 'https://studip.uni-passau.de/studip/api.php/');
client.getAuthorizationUrl('example://oauth_callback').then((String url) {
// Get verifier by calling the returned link and approve access
return FlutterWebAuth2.authenticate(url: url, callbackUrlScheme: 'example');
}).then((uri) {
// Retrieve permanent token
final verifier = Uri.parse(uri).queryParameters['oauth_verifier'] ?? '';
return client.retrieveAccessToken(verifier);
}).then((void v) {
// Example call
return client.apiGetJson('user');
}).then((dynamic decoded) {
// Example parsing of response
print(decoded['name']['formatted']);
});
}
copied to clipboard
Features and bugs #
Please file feature requests and bugs at the issue tracker.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.