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

Resolve token from session #146

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Route::get('/facebook/callback', function(SammyK\LaravelFacebookSdk\LaravelFaceb

$fb->setDefaultAccessToken($token);

// Save for later
// Save in session so that the token is loaded on the next request. Do not change the session variable name.
Session::put('fb_user_access_token', (string) $token);

// Get basic info on the user from Facebook.
Expand Down
7 changes: 7 additions & 0 deletions src/LaravelFacebookSdk/LaravelFacebookSdkServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ public function register()

return new LaravelFacebookSdk($app['config'], $app['url'], $config);
});

$this->app->resolving('SammyK\LaravelFacebookSdk\LaravelFacebookSdk', function($obj, $app) {
/** @var \SammyK\LaravelFacebookSdk\LaravelFacebookSdk $obj */
if ($accessToken = session()->get('fb_user_access_token')) {
$obj->setDefaultAccessToken($accessToken);
}
});
}

private function isLumen()
Expand Down