This is the official L²P API Reference Client. The client is written in C# and can be used for multiple platform projects (e.g. Windows, Android, iOS, ASP.Net, Linux/Unix). The client contains mechanisms for obtaining and managing the tokens as well as calling the L²P API.
The client contains the file L2PAPIClientPortable/ConfigSample.cs in which you have to add your client ID you got from ITC/CiL.
Rename file to Config.cs and save. The client is now working.
Optional: For now, the Application will store the tokens in static internal variables. By quitting the Application, the tokens are not available anymore. If you want to use a persistent storage (e.g. files or property dictionary of the smartphone), change the getters and setters in this file too. It will be the only file that needs to be changed to enable persistent device-oriented storage.
To start the Authorization process, you get the URL for the user by:
Open the URL in a browser according to the platform. The user can now login and authorize your app. You can wait some seconds and check the status for the process by:
You may want to iterate this step several times (depending on network and user speed, this may take way more time). The CheckAuthenticationProgressAsync() method will force the client to update the current state on authorization of the app. The state can be checked via the getState() every time during the application lifecycle and provides information whether the client can use API Calls.
If the app is authorized, you can simply use the calls from api.Calls namespace inside the project, like
var courses = await L2PAPIClientPortable.api.Calls.L2PviewAllCourseInfoByCurrentSemester(); // Get All Information about courses of the current semester
The tokens, http-methods and parameter-ordering will be done automatically in the background.
After the user authorized the app, the AuthenticationManager will automatically refresh the accessToken when it gets invalidated by timeout in the OAuth. If also the refreshToken gets invalidated (e.g. user unauthorizes the app) the state of the client is reset and API calls throw well-defined Exceptions.
In the L2PAPITestApplication program you can find more examples how to use the client.
Every mathod that uses network connections is provided asynchronously. All frameworks and NuGet-packages referenced are completely portable and free. The client itself is free to use and Open Source.
This client has been tested with Windows, UWP, Windows Phone, Android (Xamarin), iOS (Xamarin), Linux/Unix (Mono), OS X
The Reference client can be founf in the RWTH Gitlab