GithubHelp home page GithubHelp logo

gavronek / l2paccess-win Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 206 KB

RWTH L2P Access for Windows universal apps (WP + Windows). Manage authentication using RWTH OAuth and small framework for accessing L2P Api

License: Apache License 2.0

C# 100.00%

l2paccess-win's Introduction

Welcome at the L2PAccess project!

The aim of this project to support the development of Windows Phone and other Windows third-party apps for RWTH Aachen's new L2P teaching and learning platform. This project will provide an easy way to call methods on the L2P API without the need to worry about authentication. Authentication, which means everything from getting user code, verifying it, fetching and refreshing access tokens, will be handled automatically by the provided L2P client.


Table of Contents

Usage

Add to your project

As the project is only available in source form, you have to add the whole project to your solution. Do not worry, that's simpler than you think, just follow the steps below!

Step 1 - Download

Click on the link above or below, download the project as a Zip and extract it somewhere on your computer. Download as Zip

Step 2 - Include in solution

Ok, now you have to copy the whole project folder in the working directory of your app. Assuming DemoWPApp is a project created by Visual Studio 2013 Pivot App template it would look like something like this:

Copy from Zip to App

Now open Visual Studio and on the Solution Explorer right click on your solution and press Add > Existing project... then navigate to your project folder and add L2PAccess.csproj

enter image description here

Step 3 - Reference it

The last step you need to do is to add a reference to this newly added project from your main project. Right click on your Windows Phone project and press Add > Reference then select the L2PAccess project:

enter image description here

How to use

The goal was to create something very simple to use, so you can concentrate more on actually what you want to do.

Configure

To instantiate an L2PClient you will need a OAuthConfig object. There are two ways to do this:

  • Using an RwthConfig object with your ClientID, like this:
var config = RwthConfig.Create("YOUR_CLIENT_ID");
  • Using the OAuthConfig directly, like I did in the RwthConfig:
  new OAuthConfig
            {
                ClientId = clientId,
                OauthServerUrl = "https://oauth.campus.rwth-aachen.de/",
                InjectQueryParam = true,
                Scopes = new List<string>
                {
                    "l2p.rwth", 
                    "campus.rwth",
                    "l2p2013.rwth"
                }
            };

Your first call

Oh, this is simple. Just create an L2PClient instance using the config object we just did and call the L2P method of choice. Voilà!

l2PClient = new L2PClient(config);
var viewAllCourseInfo = await l2PClient.ViewAllCourseInfo();

Enjoy

Really, just only this step left :) Hope you will have to get your hands dirty somewhere else in your project. Good luck!


Extend

Adding L2P methods

The list of available L2P methods on the client is very limited as this was not the main goal of the project. But the way to extend the list is very easy only two things is needed:

Step 1 - Add to the API interface

Just go to the IL2PApi interface and add a line like this:

        [Get("/viewCourseInfo")]
        Task<L2PResponse<Course>> ViewCourseInfo([AliasAs("cid")] string courseId);

The annotation both for the method and the parameter uses the REFIT project, so it is highly recommended to take a look at that. As most of the L2P methods returns with the same outer structure, a generic L2PResponse class is provided. If you need to add your own model classes (like Wiki, Announcement, etc.) i recommend to store it under the API.Model folder.

Note: You don't need an access_token parameter on your L2P method call, it will be injected autmagically

Step 2 - Extend the proxy client


Now you have added the method to the Refit interface, you need to add a new method in the L2PClient, which corresponds to the one on your interface:

        public async Task<L2PResponse<Course>> ViewCourseInfo(string courseId)
        {
            var l2PResponse = await client.ViewCourseInfo(courseId);
            return l2PResponse;
        }

Why do you need this? Because L2PClient makes sure that you don't need the access_token parameter on your method and that it will be injected at runtime. In case of problems

If you found some problems with the library or have some ideas what to develop, feel free to leave an issue here: Issues page

Leave one even if you just don't understand something and need somewhere more detailed documentation.

Note: This is an open source project, I work on it in my barely existing freetime, so feel free to actually fix things yourself if you have to.


l2paccess-win's People

Contributors

gavronek avatar

Watchers

James Cloos avatar

Forkers

bbashir

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.