Skip to content

Commit

Permalink
Improve example code for fetchUserProfile stub
Browse files Browse the repository at this point in the history
- Add a `profile` object
- Indent code snippets with 2 spaces, not 1
- Add a `TODO` to make it more obvious it's not implemented
- Correct casing in `OAuth2` and add space after `API`
- Add a more complete example
  • Loading branch information
jamietanna committed Sep 13, 2021
1 parent c1ea444 commit 8a95be8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/public/react/components/ConnectionModal.react.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ var ConnectionModal = React.createClass({
connection: this.props.connection || {strategy:'oauth2', options: {scripts: {
fetchUserProfile: [
'function(accessToken, ctx, cb) {',
' // call oauth2 APIwith the accesstoken and create the profile',
' cb(null, profile);',
' var url = \'https://oauth2provider.com/oauth/authorize\'; // TODO replace with actual url',
' request.get(url, {',
' headers: { Authorization: \'Bearer \' + accessToken },',
' json: true',
' }, function(err, resp, profile) {',
' if (err) return cb(err);',
' if (resp.statusCode !== 200) return cb(new Error(\'StatusCode: \' + resp.statusCode));',
' profile.user_id = profile.id;',
' cb(null, profile);',
' });',
'}'
].join('\n')
}}, enabled_clients: undefined},
Expand Down

0 comments on commit 8a95be8

Please sign in to comment.