Giter Site home page Giter Site logo

Comments (16)

adamwathan avatar adamwathan commented on August 18, 2024

Can you show me your code? It won't save Facebook profile data automatically, you need to save the data you want to keep however your data is structured.

For example, this call will create a user and associate them with the Facebook account they logged in as, but it won't save any Facebook data, like their username, email, profile photo, etc.

SocialAuth::login('facebook')

This on the other hand will save the full name and email returned from Facebook:

SocialAuth::login('facebook', function ($user, $details) {
    $user->name = $details->full_name;
    $user->email = $details->email;
});

It's up to you to store that data if you need it, by doing whatever you want with it in that closure.

I just tested the latest versions of everything locally and not seeing any issues here.

from eloquent-oauth-l5.

wilcho-vnz avatar wilcho-vnz commented on August 18, 2024

Hi Adam,

This is the Route that does not works

Route::get('facebook/login', function() {
    try {
        SocialAuth::login('facebook', function($user, $details) { // this line does not works to get the user data to store it in the database
          $user->nickname = $details->nickname;
          $user->name = $details->full_name;
          $user->profile_image = $details->avatar;
          $user->save();
        });
    } catch (ApplicationRejectedException $e) {
        // User rejected application
    } catch (InvalidAuthorizationCodeException $e) {
        // Authorization was attempted with invalid
        // code,likely forgery attempt
    }

    // Current user is now available via Auth facade
    $user = Auth::user();

    return Redirect::intended();
});

Develop on my localhost does affect the flow of the authentication?

Thanks for your reply

from eloquent-oauth-l5.

adamwathan avatar adamwathan commented on August 18, 2024

Are you seeing an error at all, or is the data just not saving? What happens when you dd($details) in the closure?

from eloquent-oauth-l5.

wilcho-vnz avatar wilcho-vnz commented on August 18, 2024

I get this error
Undefined variable: details

This is what I receive on my route after the facebook auth:

http://localhost:8000/facebook/login?code=AQCfDCRs7Q_3pEBLAzNkhx7OWZtilnbKObQ5JhFG-IoHO7CpwqIa8e5aWevlEFOeSmpCgHKw77kJHGZTl0zd9lRtO7cczZeNdreGOqCUlmPG53KK2OF-4ygLsXzLCtdOTSf7jtjopklFwv-7TGTSwLDO6Sn1L4Yypde3UHOCNgPY-30RtmOseB7gz6g22ppoMV2Gh5oF43I1VWsI5VpLU3PmJpNKscbphmFmZ09bYDP0jeeskRnHVxBpaOgcsDAdwOpwgKuFYLAm5lv82DAP6DGRZ5OamgbIIxbT5N29ixEhcJy2FHIio7HHC9__YIDDLyu1CghPNfeYu6qk_wnwxj5j&state=5pg1fQfAYUjIbwDVS1vQb8XOxLXkHXZL#_=_

from eloquent-oauth-l5.

adamwathan avatar adamwathan commented on August 18, 2024

And that is being triggered when you call $details->nickname inside the closure? Super unusual... Any chance you can do dd(func_get_args()) inside the closure and post the results?

from eloquent-oauth-l5.

wilcho-vnz avatar wilcho-vnz commented on August 18, 2024

No, no, no.
That chain is the URL that returns Facebook ti my browser after authorize the app.
dd($details->nickname) returns: Undefined variable: details

from eloquent-oauth-l5.

adamwathan avatar adamwathan commented on August 18, 2024

No I meant the error is happening in the closure. Can you try the func_get_args thing I was talking about?

Route::get('facebook/login', function() {
    try {
        SocialAuth::login('facebook', function($user, $details) {
          dd(func_get_args());
          $user->nickname = $details->nickname;
          $user->name = $details->full_name;
          $user->profile_image = $details->avatar;
          $user->save();
        });
    } catch (ApplicationRejectedException $e) {
        // User rejected application
    } catch (InvalidAuthorizationCodeException $e) {
        // Authorization was attempted with invalid
        // code,likely forgery attempt
    }

    // Current user is now available via Auth facade
    $user = Auth::user();

    return Redirect::intended();
});

from eloquent-oauth-l5.

wilcho-vnz avatar wilcho-vnz commented on August 18, 2024

SocialAuth::login('facebook', function($user, $details) does not execute, so I can't see what dd(func_get_args()) print
Maybe I am missing something configuring the Facebook app

from eloquent-oauth-l5.

adamwathan avatar adamwathan commented on August 18, 2024

Any chance you can share the file that the error is occurring in and the exact error message? I don't understand how you were getting "Undefined variable $details" if the closure was never executing.

from eloquent-oauth-l5.

twisctid avatar twisctid commented on August 18, 2024

I'm having the EXACT same problem. after facebook redirects nothing happens

EDIT
well actually. its really throwing an InvalidAuthorizationCodeException. Perhaps that's what's happening to you as well wilcho-vnz

from eloquent-oauth-l5.

wilcho-vnz avatar wilcho-vnz commented on August 18, 2024

But, you get an error(InvalidAuthorizationCodeException) and your app dies or Facebook redirect to your callback URL configured in your Facebook App after the authorization but with no data?

from eloquent-oauth-l5.

adamwathan avatar adamwathan commented on August 18, 2024

What error are you seeing and on what line? Can you share something
reproducible? Open source a small example app that demonstrates the problem
maybe? Would really help me out in either fixing the bug or helping you
with something you are doing incorrectly.
On Thu, Mar 10, 2016 at 10:16 PM twisctid [email protected] wrote:

I'm having the EXACT same problem. after facebook redirects nothing happens


Reply to this email directly or view it on GitHub
#35 (comment)
.

from eloquent-oauth-l5.

twisctid avatar twisctid commented on August 18, 2024

i removed the try catch to see what was happening and thats what i got. so the facebook redirect works and the method is executed but it throws the error.... not sure if its due to absent data .

i'm using a clean install of Laravel 5.2, this is the only module added so far.

i attached the error page and here are the routes

Route::get('facebook/authorize', function() {
return SocialAuth::authorize('facebook');
});

Route::get('facebook/login', function() {

SocialAuth::login('facebook');

// Current user is now available via Auth facade
$user = Auth::user();

return Redirect::intended();

});

i know my fb config is legit because i used the exact same fb app on a previous version of my site built on drupal

if it comes to it i'll open source an app in the morning to demonstrate

error.html.zip

from eloquent-oauth-l5.

adamwathan avatar adamwathan commented on August 18, 2024

@twisctid Make sure your routes are defined inside the web group to ensure sessions are enabled. Can you post your routes file and any relevant controllers?

from eloquent-oauth-l5.

twisctid avatar twisctid commented on August 18, 2024

my controllers only return views. no extra code in any of them
routes.php.zip

from eloquent-oauth-l5.

twisctid avatar twisctid commented on August 18, 2024

I just verified that facebook is indeed returning data by putting dd($details) inside my closure
UPDATE
making progress. not only is fb returning data but the module is creating the user and associating it. still no session though. i'll continue to investigate
UPDATE
solved
as it turns out i have to use a closer for it to retrieve anything. secondly need to ensure the sessions folder is writeable, thirdly ALL the routes should be in the web group for auth to work

from eloquent-oauth-l5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.