Skip to content

Instantly share code, notes, and snippets.

@shortthirdman
Created June 3, 2017 08:15
Show Gist options
  • Save shortthirdman/866933d328cdfb27494019e521c0af1a to your computer and use it in GitHub Desktop.
Save shortthirdman/866933d328cdfb27494019e521c0af1a to your computer and use it in GitHub Desktop.
Authentication Provider to Social Networking Site for Sign-In/Sign-Up
$authProvider.httpInterceptor = function() { return true; },
$authProvider.withCredentials = false;
$authProvider.tokenRoot = null;
$authProvider.baseUrl = '/';
$authProvider.loginUrl = '/auth/login';
$authProvider.signupUrl = '/auth/signup';
$authProvider.unlinkUrl = '/auth/unlink/';
$authProvider.tokenName = 'token';
$authProvider.tokenPrefix = 'satellizer';
$authProvider.tokenHeader = 'Authorization';
$authProvider.tokenType = 'Bearer';
$authProvider.storageType = 'localStorage';
// Facebook
$authProvider.facebook({
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 }
});
// Google
$authProvider.google({
url: '/auth/google',
authorizationEndpoint: 'https://accounts.google.com/o/oauth2/auth',
redirectUri: window.location.origin,
requiredUrlParams: ['scope'],
optionalUrlParams: ['display'],
scope: ['profile', 'email'],
scopePrefix: 'openid',
scopeDelimiter: ' ',
display: 'popup',
oauthType: '2.0',
popupOptions: { width: 452, height: 633 }
});
// GitHub
$authProvider.github({
url: '/auth/github',
authorizationEndpoint: 'https://github.com/login/oauth/authorize',
redirectUri: window.location.origin,
optionalUrlParams: ['scope'],
scope: ['user:email'],
scopeDelimiter: ' ',
oauthType: '2.0',
popupOptions: { width: 1020, height: 618 }
});
// Instagram
$authProvider.instagram({
name: 'instagram',
url: '/auth/instagram',
authorizationEndpoint: 'https://api.instagram.com/oauth/authorize',
redirectUri: window.location.origin,
requiredUrlParams: ['scope'],
scope: ['basic'],
scopeDelimiter: '+',
oauthType: '2.0'
});
// LinkedIn
$authProvider.linkedin({
url: '/auth/linkedin',
authorizationEndpoint: 'https://www.linkedin.com/uas/oauth2/authorization',
redirectUri: window.location.origin,
requiredUrlParams: ['state'],
scope: ['r_emailaddress'],
scopeDelimiter: ' ',
state: 'STATE',
oauthType: '2.0',
popupOptions: { width: 527, height: 582 }
});
// Twitter
$authProvider.twitter({
url: '/auth/twitter',
authorizationEndpoint: 'https://api.twitter.com/oauth/authenticate',
redirectUri: window.location.origin,
oauthType: '1.0',
popupOptions: { width: 495, height: 645 }
});
// Twitch
$authProvider.twitch({
url: '/auth/twitch',
authorizationEndpoint: 'https://api.twitch.tv/kraken/oauth2/authorize',
redirectUri: window.location.origin,
requiredUrlParams: ['scope'],
scope: ['user_read'],
scopeDelimiter: ' ',
display: 'popup',
oauthType: '2.0',
popupOptions: { width: 500, height: 560 }
});
// Windows Live
$authProvider.live({
url: '/auth/live',
authorizationEndpoint: 'https://login.live.com/oauth20_authorize.srf',
redirectUri: window.location.origin,
requiredUrlParams: ['display', 'scope'],
scope: ['wl.emails'],
scopeDelimiter: ' ',
display: 'popup',
oauthType: '2.0',
popupOptions: { width: 500, height: 560 }
});
// Yahoo
$authProvider.yahoo({
url: '/auth/yahoo',
authorizationEndpoint: 'https://api.login.yahoo.com/oauth2/request_auth',
redirectUri: window.location.origin,
scope: [],
scopeDelimiter: ',',
oauthType: '2.0',
popupOptions: { width: 559, height: 519 }
});
// Bitbucket
$authProvider.bitbucket({
url: '/auth/bitbucket',
authorizationEndpoint: 'https://bitbucket.org/site/oauth2/authorize',
redirectUri: window.location.origin + '/',
optionalUrlParams: ['scope'],
scope: ['email'],
scopeDelimiter: ' ',
oauthType: '2.0',
popupOptions: { width: 1020, height: 618 }
});
// Spotify
$authProvider.spotify({
url: '/auth/spotify',
authorizationEndpoint: 'https://accounts.spotify.com/authorize',
redirectUri: window.location.origin,
optionalUrlParams: ['state'],
requiredUrlParams: ['scope'],
scope: ['user-read-email'],
scopePrefix: '',
scopeDelimiter: ',',
oauthType: '2.0',
popupOptions: { width: 500, height: 530 }
});
// Generic OAuth 2.0
$authProvider.oauth2({
name: null,
url: null,
clientId: null,
redirectUri: null,
authorizationEndpoint: null,
defaultUrlParams: ['response_type', 'client_id', 'redirect_uri'],
requiredUrlParams: null,
optionalUrlParams: null,
scope: null,
scopePrefix: null,
scopeDelimiter: null,
state: null,
oauthType: null,
popupOptions: null,
responseType: 'code',
responseParams: {
code: 'code',
clientId: 'clientId',
redirectUri: 'redirectUri'
}
});
// Generic OAuth 1.0
$authProvider.oauth1({
name: null,
url: null,
authorizationEndpoint: null,
redirectUri: null,
oauthType: null,
popupOptions: null
});
/*
<button ng-click="authenticate('facebook')">Sign in with Facebook</button>
<button ng-click="authenticate('google')">Sign in with Google</button>
<button ng-click="authenticate('github')">Sign in with GitHub</button>
<button ng-click="authenticate('linkedin')">Sign in with LinkedIn</button>
<button ng-click="authenticate('instagram')">Sign in with Instagram</button>
<button ng-click="authenticate('twitter')">Sign in with Twitter</button>
<button ng-click="authenticate('foursquare')">Sign in with Foursquare</button>
<button ng-click="authenticate('yahoo')">Sign in with Yahoo</button>
<button ng-click="authenticate('live')">Sign in with Windows Live</button>
<button ng-click="authenticate('twitch')">Sign in with Twitch</button>
<button ng-click="authenticate('bitbucket')">Sign in with Bitbucket</button>
<button ng-click="authenticate('spotify')">Sign in with Spotify</button>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment