Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth token expiry #3

Open
EttoreRaimondi opened this issue May 15, 2019 · 3 comments
Open

Auth token expiry #3

EttoreRaimondi opened this issue May 15, 2019 · 3 comments

Comments

@EttoreRaimondi
Copy link

Hey guys, cant seems to find the answer anywhere. Could you please tell me how long this token stays active for? How long before it expires?

@jvdoorn
Copy link
Contributor

jvdoorn commented May 15, 2019

If I remember correctly.. we don't know either. This token is provided by Magister if you were to log in using a browser, it changes every now and then.

The fact that you don't know when it changes, and thus not knowing when to update the token is a bit annoying. There are three things you can do:

  1. Before running your code, update packages (npm up). That should fetch the latest version of the package and update your token.

  2. Use magisterjs-dynamic-authcode, this will allow you to fetch the latest version of the authcode and provide it to MagisterJS.

  3. Query the code yourself using an HTTP-GET request (see the README.md).

The first option is probably the only convenient if you are running MagisterJS from a script (you could then just run npm up before node your-script-using-magister.js). The second and third option are probably best to use when you distribute the code and don't want end users to have the hastle of having to run npm up before using your code (and when you package it using electron par example this is probably not possible even).

@EttoreRaimondi
Copy link
Author

Thanks so much for the reply.

Currently I'm querying the url for the Auth code. works well :) was just curious as to expiry time.

We are working on an old laravel 4, php 5.6 project that makes use of magister. The only difficulty in debugging issues is that there is no real documentation for anything that was done. The project has taken the web scraping approach and therefore makes it even more difficult. We would like to use a REST API where possible but cant seem to find any documentation. Any tips here?

@jvdoorn
Copy link
Contributor

jvdoorn commented May 15, 2019

You could take a look at how MagisterJS handles things, it might be easier to port the Javascript code to PHP/Laravel than to update the existing code. The reason for this is that Magister changed quite some stuff so that code possibly doesn't even work at all and secondly, MagisterJS makes use of the Magister's API (which Magister uses to fetch your appointments, grades, etc.) which is probably a better approach then scraping the data.

If you go to your school's Magister and look at the network tab in your inspector (that's on Firefox at least, not sure what it's called on Chrome or other browsers) you can see the requests Magister makes to the API.

You could also let the PHP/Laravel stuff maybe use MagisterJS? I don't really know PHP so I'm not sure if you could call node scripts from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants