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

Expected application/json response, got text/html after moving to web server #65

Closed
yodyyyy opened this issue Mar 24, 2017 · 3 comments
Closed

Comments

@yodyyyy
Copy link

yodyyyy commented Mar 24, 2017

I've problem with getting error "Expected application/json response, got text/html ". On my localhost it works well but not from web server. I'm running Pl*sk and base with FatFreeFramwork, tried to switching php version but nothing happens, even to put "curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);" into broker.php as @petitbx said. But for php 7.0 i got this error "Broker didn't send a session key".
Thx

php 7.1

php 7.0.15

@yodyyyy yodyyyy changed the title Expected application/json response, got text/html when tried to moving to web server Expected application/json response, got text/html after moving to web server Mar 24, 2017
@jasny
Copy link
Owner

jasny commented Mar 29, 2017

The error is pretty explicit. The Broker didn't receive JSON from the server. Maybe the URL is misconfigured or there is somekind of server error. I can't tell. You need to debug to see what the server has send.

@jasny jasny closed this as completed Mar 29, 2017
@yodyyyy
Copy link
Author

yodyyyy commented Apr 7, 2017

i think the most problem with getallheaders(), as example running with PHP-FPM. So maybe you must put this code on your script

public function getallheaders() {
    $headers = [];
    foreach ($_SERVER as $name => $value) {
        if (substr($name, 0, 5) == 'HTTP_') {
            $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
        }
    }
    return $headers;
    }

thank you, sorry for bad english

@awnali
Copy link

awnali commented Jun 12, 2017

I got the same error while integrating it with Laravel 5.4. This is how i solved it:
Go to Login method of Jasny\SSO\Server class, core library (must be in vendor folder). change last line to, return $this->userInfo();
Then go to userInfo method and change the last line to: return $user;

Now return from your controller with json header, for example in case of laravel i did:
return response()->json([ 'user' => $user ]);

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

3 participants