Authentication SDK for PHP loop

I spent hours of toil, to eliminate all the other reasons I've even hmoshpl my application back to the two pages contentless. This is my index php http://pastebin.com/0UmLWgew.

Essentially, when a user accessed the application the first time are forwarded to the permissions page. After you click allow (and indeed the following to the application) are stuck in a loop migration. Looking through my history theres loads of myapp.com/app/code? = xxxxxxxxxxxxxxxxxxxx

Don't know what to do, I thought the SDK handled fully the logon process, I have to grab the code and do something with this? I'm running v 3.1 of the SDK by the way.

Last edited by rubberducky (now 09: 06: 59)