FriendsOfFlarum / passport

The Laravel passport compatible oauth extension for your Flarum forum.
https://discuss.flarum.org/d/5203
MIT License
27 stars 12 forks source link

Problems with Laravel 8 and Flarum Beta16 #18

Closed Benoit1980 closed 3 years ago

Benoit1980 commented 3 years ago

Hello,

I am unable to get the the autorization to work between Flarum and Laravel 8. Is this package working with Laravel 8?

Here is my configuration: Flarum:

    "devDependencies": {
        "flarum": "0.1.0-beta.16",
        "prettier": "^2.2.1"
    }

    "require": {
        "flarum/approval": "^0.1.0",
        "flarum/bbcode": "^0.1.0",
        "flarum/core": "^0.1.0",
        "flarum/emoji": "^0.1.0",
        "flarum/flags": "^0.1.0",
        "flarum/lang-english": "^0.1.0",
        "flarum/likes": "^0.1.0",
        "flarum/lock": "^0.1.0",
        "flarum/markdown": "^0.1.0",
        "flarum/mentions": "^0.1.0",
        "flarum/nicknames": "^0.1.0",
        "flarum/pusher": "^0.1.0",
        "flarum/statistics": "^0.1.0",
        "flarum/sticky": "^0.1.0",
        "flarum/subscriptions": "^0.1.0",
        "flarum/suspend": "^0.1.0",
        "flarum/tags": "^0.1.0",
        "fof/passport": "^0.6.0"
    },

Laravel:

   "require": {
        "php": "^7.3",
        "ext-dom": "*",
        "aws/aws-sdk-php": "^3.176.2",
        "fideloper/proxy": "^4.4.1",
        "fruitcake/laravel-cors": "^1.0.6",
        "guzzlehttp/guzzle": "^7.3.0",
        "laravel/cashier-paddle": "^1.4.4",
        "laravel/framework": "^8.34.0",
        "laravel/legacy-factories": "^1.1.0",
        "laravel/passport": "^10.1",
        "laravel/telescope": "^4.4.6",
        "laravel/tinker": "^2.6.1",
        "laravel/ui": "^3.2.0",
        "spatie/laravel-permission": "^3.18.0"
    },

I have installed Laravel in my public_html folder(and it is working well). I have also installed the passport feature. Flarum is installed at http://mywebsite.dev/forum

This is the request sent from the "Authorize page" on the Flarum side(login button)

https://website.dev/oauth/authorize
?scope=
&state=6931b2103c6208d4e981c30e8a20dfaf
&response_type=code
&approval_prompt=auto
&redirect_uri=https%3A%2F%2Fwebsite.dev%2Fforum%2Fauth%2Fpassport
&client_id=7

The the popup keeps showing: An error occurred while trying to load this page.

This is the client records in my laravel Database:

 `oauth_clients` (`id`, `user_id`, `name`, `secret`, `provider`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `created_at`, `updated_at`) 
VALUES (7, 10, 'Forum', '9cjUAcKvaJ7aEig0j6jz5F9HEw36qL6G86DEqonG', NULL, 'https://website.dev/forum/auth/passport', 1, 1, 0, '2021-05-15 16:07:19', '2021-05-15 16:07:19');

I really cannot work out why it ia not working.

luceos commented 3 years ago

If your forum is installed at http://mywebsite.dev/forum how then is the redirect starting with https://mywebsite.dev/forum? Make sure to use http everywhere, not https.

Benoit1980 commented 3 years ago

Thank you for the reply. In your documentation it says: "Hint: When creating the OAuth client in your Laravel app, don't forget to set the redirect value to<your flarum install>/auth/passport or you might encounter invalid_client errors."

My Flarum installation path is: https://mywebsite.dev/forum/

This is why I added the url in this way.

clarkwinkelmann commented 3 years ago

Daniel was referring to the use of http vs https in your various shared URLs, but the http in the forum URL could be a typo and you might be in fact using HTTPS (?) the path/suffix looks fine.

An error occurred while trying to load this page

If that error is shown while on the Laravel domain, there must be a Laravel related error logged somewhere. Do you see anything in the Laravel log file or system log file?

Benoit1980 commented 3 years ago

Yes sorry this was a typo in my text, the urls are all https. No Laravel errors in the log no sorry. I think I will install Telescope tonight and see if I can get anything logged in it rather than the typical Laravel log. I will let you know asap

clarkwinkelmann commented 3 years ago

I have just tested the latest version of fof/passport and not experienced any issue. There is no major change between the beta 16 and Flarum 1.0 versions.

I'm closing this for now but feel free to re-open if you have additional details.