Skip to content

Commit

Permalink
add Authorization header for oauth2 Bearer token
Browse files Browse the repository at this point in the history
  • Loading branch information
ds1371dani committed Jun 23, 2023
1 parent e0f749e commit 49254cf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drf_spectacular/templates/drf_spectacular/swagger_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ const injectAuthCredentials = (request) => {
} else if (authDef.schema.type === "apiKey" && authDef.schema.in === "header") {
request.headers[authDef.schema.name] = authDef.value;
return;
} else if (authDef.schema.type === "oauth2" && authDef.token.token_type === "Bearer") {
request.headers["Authorization"] = `Bearer ${authDef.token.access_token}`;
return;
}
}
};
Expand Down

0 comments on commit 49254cf

Please sign in to comment.