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

Is anyone successfully testing this on heroku? #120

Closed
eriko opened this Issue Mar 30, 2016 · 25 comments

Comments

Projects
None yet
4 participants
@eriko
Copy link

commented Mar 30, 2016

From leaving a trail of breadcrumb error_log's through the code it does not seem to be setting anything in the session durning /public/oauth2response.php setup. This means userid/api is not saved to the database and the rest fails.

@bagofarms

This comment has been minimized.

Copy link
Contributor

commented Mar 30, 2016

Are you using the latest version? I just fixed some bugs yesterday related to saving to the database. Also, @iturgeon should have some input, since he is the one that developed the Heroku compatibility.

@eriko

This comment has been minimized.

Copy link
Author

commented Mar 30, 2016

Yep I switched over yesterday afternoon with the same results. I had been slowing working back up the tree to find where things started to fail and this is as far as I got.

@iturgeon

This comment has been minimized.

Copy link
Member

commented Apr 6, 2016

This is on my radar, just busy atm. I'll investigate when I can.

@eriko

This comment has been minimized.

Copy link
Author

commented Apr 6, 2016

I found something further odd in that certain users could access it enough to authorize but not when they ran the report nothing would happen. There was still nothing stored in the database.

@cooperfellows

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2016

@eriko Using the latest release (v2.0.4) with the changes I mentioned in #139 and the fix implemented in #138, I am able to deploy to Heroku using the Instant deploy technique.

@bagofarms

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2016

I just merged #140 , which solves #138 (Thanks @cooperfellows !)

Closing this issue.

@bagofarms bagofarms closed this Apr 22, 2016

@eriko

This comment has been minimized.

Copy link
Author

commented Apr 22, 2016

This fixes the db creation issues but did not fix the saving data issue. I wonder if it is an issue that I am testing this on the free engine of heroku.

@cooperfellows

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2016

@eriko I am also using the free engine on Heroku and can confirm that the reports run, and are stored in the database. From the stored result I was able to create a PDF. Can you tell me a bit more about the problems you are seeing? Maybe I can help track them down.

On Monday I will try to deploy from scratch and see how it goes.

@bagofarms

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2016

My apologies. I am in an issue closing mood today. Reopening until your issue is fully resolved.

@bagofarms bagofarms reopened this Apr 22, 2016

@bagofarms bagofarms added the question label Apr 22, 2016

@cooperfellows

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2016

Quick follow up, the stored reports are not working correctly after leaving a course and coming back to it. They only worked while I remained on the UDOIT app page (so not really working as intended). I will dig further into this next week.

@eriko

This comment has been minimized.

Copy link
Author

commented Apr 22, 2016

Closing tickets is satisfying so no problem.

I nuked both the app and the dev keys and started fresh.

Basically after the requesting access page "UDOIT is requesting access to your account."

I get now get an error of
" Authentication problem: Please contact support."

In looking at the now created db tables I would expect that after auth there would be a user record but there is not any thing in the users table.

My suspicion from previous debugging is that session setup is failing.

@bagofarms

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2016

Ok, so that error is generated on this line: https://github.com/ucfcdl/UDOIT/blob/d132e47f256f8db9159520d4f74f2546762d4512/public/oauth2response.php#L72

That means the response you got back from Canvas did not contain an API key and refresh code. Print out the full response from Canvas to see if you are getting an error message.

@eriko

This comment has been minimized.

Copy link
Author

commented Apr 22, 2016

So when I was last working on this and working my why back up the code base I found that the session was not sticking and this would fail.

I generally write ruby and one of the reasons I was happy to stop supporting moodle was no more PHP. So how would you suggest getting the response as
printError('Authentication problem: Please contact support. '. $response);
does not get me anything.

@bagofarms

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2016

On line 69 of that file, you can put print_r($response);, which will print out the whole object Canvas gives back to you. My suspicion is that there is a clue hidden in that response object that will help us figure this out.

@eriko

This comment has been minimized.

Copy link
Author

commented Apr 22, 2016

That should in theory dump in to heroku logs and not on the page?

2016-04-22T21:06:55.775759+00:00 app[web.1]: 10.140.242.237 - - [22/Apr/2016:21:06:55 +0000] "POST / HTTP/1.1" 302 29070 "https://canvas.evergreen.edu/courses/144/external_tools/205" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
2016-04-22T21:06:56.402213+00:00 heroku[router]: at=info method=GET path="/oauth2response.php" host=udoit-evergreen.herokuapp.com request_id=b0aae6d0-cd64-410d-9e0e-6a6a31e551ee fwd="192.211.24.12" dyno=web.1 connect=0ms service=2ms status=200 bytes=1021
2016-04-22T21:06:56.402638+00:00 app[web.1]: 10.136.156.148 - - [22/Apr/2016:21:06:56 +0000] "GET /oauth2response.php HTTP/1.1" 200 655 "https://canvas.evergreen.edu/login/oauth2/confirm" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
2016-04-22T21:06:57.842983+00:00 app[web.1]: 10.136.156.148 - - [22/Apr/2016:21:06:57 +0000] "GET /oauth2response.php?code=41898fcb04b2fb314b8b3f108f8bddf9a4a9c94c53ea970f23677697d32e8ac8aeef15c97b6a8ac41646685566e6e6424adee8b995023104fe55389d64c02ec0 HTTP/1.1" 200 620 "https://canvas.evergreen.edu/login/oauth2/confirm" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
2016-04-22T21:06:57.842376+00:00 heroku[router]: at=info method=GET path="/oauth2response.php?code=41898fcb04b2fb314b8b3f108f8bddf9a4a9c94c53ea970f23677697d32e8ac8aeef15c97b6a8ac41646685566e6e6424adee8b995023104fe55389d64c02ec0" host=udoit-evergreen.herokuapp.com request_id=3be67ff4-1d40-42c7-8363-b03307b80c4c fwd="192.211.24.12" dyno=web.1 connect=0ms service=2ms status=200 bytes=986
2016-04-22T21:08:58.186033+00:00 heroku[router]: at=info method=POST path="/" host=udoit-evergreen.herokuapp.com request_id=7b027c45-f25e-4fd3-a987-c9c26683dd84 fwd="192.211.24.12" dyno=web.1 connect=1ms service=38ms status=302 bytes=29658
@eriko

This comment has been minimized.

Copy link
Author

commented Apr 22, 2016

I should get the resources to run this locally and I will see if that works.

@bagofarms

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2016

print_r on that line will output to the page, not the logs, since the page is being shown to the user rather than accessed directly by Canvas.

@eriko

This comment has been minimized.

Copy link
Author

commented Apr 22, 2016

Eventually doing
printError('AAAAAAAuthentication problem: Please contact support. '. print_r($response));

Got me this:

AAAAAAAuthentication problem: Please contact support. 1

New Data:
I have tested with three of my accounts. Some with and some with out SIS ids and got this to happen. Two are just teacher accounts and one is an admin. My co worker also with and admin account can get as far as requesting a report before is errors out about creating a report. I am deeply confused now.

@cooperfellows

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2016

@eriko When using print_r, you have to pass TRUE as the second parameter:
printError('AAAAAAAuthentication problem: Please contact support. '. print_r($response,TRUE));

Otherwise, as you noted, you will just get a 1 to print out.

When the return parameter is TRUE, this function will return a string. Otherwise, the return value is TRUE.

Source

I'm going to do an install from scratch today and will report back on my steps and findings.

@bagofarms

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2016

The print_r() function doesn't return the string by default, which is why I was saying to put it on line 69 so that it could output to the page.

Let's try a slightly different approach. Replace your entire oauth2response.php with the contents of this gist:
https://gist.github.com/bagofarms/13736c790f9856458ae67abdbea96388

I just tested that on my install, and it will print the raw response JSON to the screen. It should be in this format:
{"access_token":"13~1234567890","user":{"id":123456,"name":"Jacob Bates (UCF-CDL)"},"refresh_token":"13~0987654321"}

If either the access_token or refresh_token properties are missing, you are getting an incorrect response back from Canvas. If you are getting an error property back, or maybe just a number, then you're also getting a bad response back from Canvas

@cooperfellows

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2016

@eriko I just installed this from scratch and it generally works as expected (outside of the PDF throbber not working and the File Name Collision issue I filed #141).

My process was to:

  1. Click Deploy to Heroku button
  2. Name Heroku app so we know the address of the OAUTH2_URI setting
  3. Create developer key inside of Canvas (be sure the Redirect URI field matches the OAUTH2_URI field you configured in Heroku)
  4. Fill in other settings (OAUTH2_ID and OAUTH2_KEY)
  5. Add YouTube API Key (optional)
  6. Deploy App
  7. Add App in Canvas as normal
  8. Test UDOIT

I tried using UDOIT under two accounts, one an admin level account and the other a teacher level account, both worked without trouble (outside of what I mentioned above).

I tried running scans the first time around as the account that created the App and everything worked out. Then I then logged out of that account, signed back in to that account and saw my historical reports and generated PDF's based on the historical scans

I then signed in as the teacher level account (in a new browser), ran new reports and saw the other reports that had been run.

I'd double check your Oauth2 URI settings, both in the developer key settings area, and in the Heroku config area.

@eriko

This comment has been minimized.

Copy link
Author

commented Apr 25, 2016

Some success. Some Chrome config is messing with the auth cycle.

That said for all accounts, mine and others, I am getting
"Error inserting report into database" after running the scanner. This happens even if I limit the scan to announcements.

Sidenote: Thank you both for your work and help on this.

@cooperfellows

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2016

@eriko Are you sure you are running a version with the updated pg_sql creation (#140)? To confirm, can you connect to your database (help connecting to database) and tell me the datatype for the report date field? If that is not stored as timestamp with timezone (the incorrect option will be bigint) then your reports will not save.

Not sure what platform you will be connecting from, but if you use the pgAdmin tool, you can see the datatype that way. You could even then delete that row in the table and recreate it as timestamp with timezone instead of doing a brand new deployment.

@eriko

This comment has been minimized.

Copy link
Author

commented Apr 25, 2016

Sadly my computer just tanked and I am migrating to a backup mini. There is a good chance this is true and I will check it once I am back up

@eriko

This comment has been minimized.

Copy link
Author

commented Apr 26, 2016

@cooperfellows was correct about the DB as it was setup before the update.
I root issue that I started this seems to be a browser (chrome) security setting. Once figure out what it is I will let you know.

@eriko eriko closed this Apr 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.