jadjoubran / laravel5-angular-material-starter

Get started with Laravel 5.3 and AngularJS (material)
https://laravel-angular.readme.io/
MIT License
1.66k stars 400 forks source link

Authenticating with Facebook and Satellizer #413

Closed CaptainChainsaw closed 8 years ago

CaptainChainsaw commented 8 years ago

I am trying to authenticate and login using satellizer. I'm new to Laravel and have some angular experience so please bear with me. I created an app on Facebook to authenticate with and followed the instructions as best as I could. I have a "sign in with facebook" button on my login page, clicking it does nothing and there are no errors in the console. I expect I've not configured this correctly. Could you please help me set this up?

Also how can I determine which routes should only be available to authenticated users?

On the facebook app I've set:

Valid OAuth redirect URIs: http://locahost:8000 Site URL: http://locahost:8000

My login page:

    <md-content class="Page-container">
        <div class="Login-formContainer" layout="column" layout-align="center center">

           <h1 class="md-headline">Log in to your account</h1>

         <login-form></login-form>
        <button ng-click="authenticate('facebook')">Sign in with Facebook</button>
     </div>
  </md-content>

`

 export function SatellizerConfig($authProvider) {
'ngInject';

$authProvider.httpInterceptor = function() {
    return true;
}

$authProvider.loginUrl = '/api/auth/login';
$authProvider.signupUrl = '/api/auth/register';
$authProvider.tokenRoot = 'data';//compensates success response macro

$authProvider.facebook({
  clientId: '317593668600609',   // app id
  responseType: 'token',
  name: 'facebook',
  url: '/auth/facebook',
  authorizationEndpoint: 'https://www.facebook.com/v2.5/dialog/oauth',
  redirectUri: window.location.origin + '/',
  requiredUrlParams: ['display', 'scope'],
  scope: ['email'],
  scopeDelimiter: ',',
  display: 'popup',
  oauthType: '2.0',
  popupOptions: { width: 580, height: 400 }
});
 }
jadjoubran commented 8 years ago

Hi @CaptainChainsaw The $authProvider.facebook needs to be in your login-form component

CaptainChainsaw commented 8 years ago

Hi @jadjoubran

I've had a look in login-form.component.js. Please forgive my ignorance, if I want to use multiple authproviders is it a case of passing $authProvider to the constructor? I'm not really sure what I'm meant to do with this file. If there's any tutorials you can direct me to I'll happily take a look.

Thank you.

jadjoubran commented 8 years ago

Hi @CaptainChainsaw I haven't used satellizer recently.. you can find tutorials here especially the toptal article