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 not updating with magister #4

Open
EttoreRaimondi opened this issue Oct 4, 2019 · 3 comments
Open

Auth token not updating with magister #4

EttoreRaimondi opened this issue Oct 4, 2019 · 3 comments

Comments

@EttoreRaimondi
Copy link

EttoreRaimondi commented Oct 4, 2019

Hey!

Me again, so I see that the auth code is no longer in sync with magister js site? The site seems to update to a new auth code every few hours? Any idea where we can pull the updated auth code from to access the login challenge?

@robbertkl
Copy link

I've noticed the same and have created this PhantomJS script to fetch the auth code, which is what I'm using now:

var system = require('system');
var webpage = require('webpage');

if (system.args.length < 2) {
  console.log('Usage: phantomjs fetch.js school_url');
  phantom.exit(1);
}

var url = system.args[1];
var page = webpage.create();

page.onResourceRequested = function(request) {
  if (request.method == 'POST' && request.url == 'https://accounts.magister.net/challenges/current') {
    var json = JSON.parse(request.postData);
    console.log(json.authCode);
    phantom.exit(0);
  }
};

page.open(url, function() {
  setTimeout(function() {
    phantom.exit(1);
  }, 5000);
});

I'm able to automate uploading this auth code, so perhaps I can create an alternative to this repo and have a gist with the auth code that can be fetched dynamically, similar to magisterjs-dynamic-authcode.

@EttoreRaimondi
Copy link
Author

EttoreRaimondi commented Oct 8, 2019

Awesome! Had a similar idea. Would be awesome if you made the new repo as this one is technically useless now. It seems that everytime magister update their site/api, the auth code changes. Could you please add it and then link it to this issue so other's can also find it.

@robbertkl
Copy link

See https://github.com/robbertkl/magister-authcode

I have an instance fetching it every 15 minutes (it hasn't changed for a few days) to https://gist.github.com/robbertkl/995a359d1c9641892e3de1ed9af18b15

After a while we can see in the gist's revisions how often the auth code changes but I agree with you in that it's probably updated on every server update.

You can use the npm package magister-authcode as a drop-in replacement for @magisterjs/dynamic-authcode or fetch the JSON manually from this url.

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