Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
dist
.npmrc
*.tgz
.idea/
12 changes: 11 additions & 1 deletion src/Strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,17 @@ export class Strategy<TUser = object, TInfo = object> extends OAuth2Strategy {
this._oauth2.useAuthorizationHeaderforGET(true);
this._oauth2.get("https://www.patreon.com/api/oauth2/v2/identity?fields[user]=" + this.fields.join(","), accessToken, (error, result) => {

if (error) return done(new InternalOAuthError("Failed to fetch user profile", error));
if (error) {
let errorStr;
try {
const errors = JSON.parse(error.data);
errorStr = '\n' + errors.errors.map((x: any) => `${x.code_name}: ${x.detail}`).join('\n ');
}
catch (parseError) {
errorStr = '';
}
return done(new InternalOAuthError(`Failed to fetch user profile${errorStr}`, error));
}

let json: UserResponse;

Expand Down