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

401 (Unauthorized) : Can't submit a message, react to a post or save a username. #31

Open
mshahinaz29 opened this issue Feb 10, 2021 · 7 comments

Comments

@mshahinaz29
Copy link

Screenshot_531

@petertsoisstuff
Copy link

petertsoisstuff commented May 27, 2021

Looks like this is a bug of laravel/passport:^8
https://github.com/laravel/passport/blob/6affa6ed600c5f8909385fbae7cf6f8af3db2d39/src/Guards/TokenGuard.php#L251

protected function decodeJwtTokenCookie($request)
{
    return (array) JWT::decode(
        $this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies),
        $this->encrypter->getKey(),
        ['HS256']
    );
}

Upgrade to laravel/passport:^9 will fix it

Quick Fix:
Replace

$this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies),

with

substr($this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies), 41),

@KnowledgeWanderer
Copy link

Quick Fix:
Replace

$this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies),

with

substr($this->encrypter->decrypt($request->cookie(Passport::cookie()), Passport::$unserializesCookies), 41),

Having the same issue and this doesn't fix my problem sadly.

Any ideas what could be done?

@KnowledgeWanderer
Copy link

@sbarbat I tried for a few hours now and can't figure out what's wrong. Can you please provide some assistance? I really need this package to work, as it's amazing and exactly what I need for my project.

Thank you and sorry for tagging you.

@sbarbat
Copy link
Collaborator

sbarbat commented Jul 30, 2021

Sorry thaat havent got any time to look into this, will do it this weekend! 💪 @KnowledgeWanderer

@KnowledgeWanderer
Copy link

@sbarbat no need to be sorry, you did something great here, that's free and open source.
If what I want to make will work, I'll support this project and pump some money into it. Thinking of actually donating towards it nevertheless, but it has to work well first of all.

@ericleversen
Copy link

I have the same issue @sbarbat

composer.lock
Laravel 8.7
Passsport 10.2
chatter-laravel/core dev-master c3a447f

When I click the Ask a Question button I get a console error shown in attached screen shot.
The first error, api/chatter/discussion 401, happens on the click.

The second error, Error: Request failed with status code 401...app.js:2539:17, occurs on loading the new page which is the default home page /home

I'm planning (hoping) to use this in production and will happily contribute $$$ to its upkeep.

Screen Shot 2021-12-04 at 6 49 23 PM

@ericleversen
Copy link

As a follow up, if I hit the page directly it returns a properly formatted json file with chatter data.
See attached
@sbarbat
Uploading Screen Shot 2021-12-07 at 7.08.37 PM.png…

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

5 participants