-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Configurable server post object properties #346
Conversation
+1 |
I don't like that it's a global config, not to mention it's very specific to OAuth 2.0 and therefore shouldn't called authFields. google: {
name: 'google',
url: '/auth/google',
authorizationEndpoint: 'https://accounts.google.com/o/oauth2/auth',
redirectUri: window.location.origin || window.location.protocol + '//' + window.location.host,
scope: ['profile', 'email'],
scopePrefix: 'openid',
scopeDelimiter: ' ',
requiredUrlParams: ['scope'],
optionalUrlParams: ['display'],
// will override OAuth 2.0 defaults...
defaultUrlParams: ['response_type', 'client_id', 'redirect_uri', 'foo', 'bar'],
display: 'popup',
type: '2.0',
popupOptions: { width: 452, height: 633 }
}, For example, if you override this property, it will use your fields, if not, it will fallback to |
Ah, I am sorry I misunderstood your intent there. If you want to send additional params in UpdateSomewhat related issue: #237. |
Ok, I was able to kill 2 birds with 1 stone. Instead of creating new fields, I have slightly changed how the existing Here are OAuth 2.0 defaults: var defaults = {
responseParams: {
code: 'code',
clientId: 'clientId',
redirectUri: 'redirectUri'
},
defaultUrlParams: ['response_type', 'client_id', 'redirect_uri'],
responseType: 'code'
}; And here is how you can change param names, as well as add a new response field, given that your OAuth 2.0 provider is sending additional fields besides facebook: {
name: 'facebook',
url: '/auth/facebook',
authorizationEndpoint: 'https://www.facebook.com/v2.3/dialog/oauth',
redirectUri: (window.location.origin || window.location.protocol + '//' + window.location.host) + '/',
scope: ['email'],
scopeDelimiter: ',',
responseParams: {
code: 'code',
clientId: 'client_id',
redirectUri: 'redirect_uri',
domainPrefix: 'domain_prefix'
},
requiredUrlParams: ['nonce','display', 'scope'],
display: 'popup',
type: '2.0',
popupOptions: { width: 580, height: 400 }
}, Your server will receive the following object: { client_id: "....", code: "....", redirect_uri: "....", domain_prefix: "..." } |
Will this also work with a nested response? e.g. http://jsonapi.org/ |
@philippeluickx It iterates once, so just the top-level properties. |
@philippeluickx However, $auth.authenticate = function(name, userData) {
return oauth.authenticate(name, userData);
}; |
Yup, userData can be nested, have done that already so I can confirm here. |
Resolved inResolved in 0.12 release. |
It is not very flexible to have them hardcoded, especially if you have to adapt to the backend you have no control over. I'm talking about the object with
code
,clientId
andredirectUri
fields. I made a quick tweak, that allows to override default field names for custom scenarios and fall back to default values if not necessary, so the tweak doesn't break anything. I'm not sure if tests are needed for such a small tweak. But anyway, let me know. Thanks.