Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [laravel] problem z logowaniem przez facebooka
tomi001
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 7.03.2018

Ostrzeżenie: (0%)
-----


Mam taki problem mam wpisaną domenę na facebooku w tym adresie https://developers.facebook.com/apps i to jest ustawione na on nawet ustawiłem Client OAuth Login na wyłączone i to nie dało rezultatu, ale do rzeczy jak klikma zaloguj przez facrbooka to dostaje komunikat

Adres URL zablokowany: To przekierowanie nie powiodło się, ponieważ identyfikator URI nie jest na liście dozwolonych identyfikatorów w ustawieniach aplikacji klienta OAuth. Upewnij się, że klient i sieciowy login OAuth są włączone i dodaj wszystkie swoje domeny aplikacji jako ważne adresy URI przekierowań OAuth.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tomi001
post
Post #2





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 7.03.2018

Ostrzeżenie: (0%)
-----


  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use Illuminate\Foundation\Bus\DispatchesJobs;
  6. use Illuminate\Routing\Controller as BaseController;
  7. use Illuminate\Foundation\Validation\ValidatesRequests;
  8. use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
  9. use Blog\Article;
  10. use Auth;
  11. use Illuminate\Http\Request;
  12. use Socialite;
  13. class AuthController extends Controller
  14. {
  15. // Some methods which were generated with the app
  16.  
  17. /**
  18.   * Redirect the user to the OAuth Provider.
  19.   *
  20.   * @return Response
  21.   */
  22.  
  23. public function redirectToProvider($provider)
  24. {
  25. return Socialite::driver($provider)->redirect();
  26. }
  27.  
  28. /**
  29.   * Obtain the user information from provider. Check if the user already exists in our
  30.   * database by looking up their provider_id in the database.
  31.   * If the user exists, log them in. Otherwise, create a new user then log them in. After that
  32.   * redirect them to the authenticated users homepage.
  33.   *
  34.   * @return Response
  35.   */
  36. public function handleProviderCallback($provider)
  37. {
  38. $user = Socialite::driver($provider)->user();
  39.  
  40. $authUser = $this->findOrCreateUser($user, $provider);
  41. Auth::login($authUser, true);
  42. return redirect($this->redirectTo);
  43. }
  44.  
  45. /**
  46.   * If a user has registered before using social auth, return the user
  47.   * else, create a new user object.
  48.   * @param $user Socialite user object
  49.   * @param $provider Social auth provider
  50.   * @return User
  51.   */
  52. public function findOrCreateUser($user, $provider)
  53. {
  54. $authUser = User::where('provider_id', $user->id)->first();
  55. if ($authUser) {
  56. return $authUser;
  57. }
  58. return User::create([
  59. 'name' => $user->name,
  60. 'email' => $user->email,
  61. 'provider' => $provider,
  62. 'provider_id' => $user->id
  63. ]);
  64. }
  65.  
  66. }
  67.  
  68.  
  69. ?>


I jeszcze routing

  1. Route::get('aut/{provider}', 'AuthController@redirectToProvider');
  2. Route::get('aut/{provider}/callback', 'AuthController@handleProviderCallback');


A jeszcze dodam, że jak wykonam routing http://domena/laravel/public/aut/facebook/callback

To pojawia się błąd laravela.
(1/1) InvalidStateException

in AbstractProvider.php (line 209)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 8.10.2025 - 20:02