Skip to content

Commit

Permalink
Merge pull request #1017 from ds1371dani/fix/swagger_ui_oauth2_missin…
Browse files Browse the repository at this point in the history
…g_authorization

add Authorization header for oauth2 in swagger ui schema request
  • Loading branch information
tfranzel authored Jul 9, 2023
2 parents ec8ba7f + 49254cf commit 31665a3
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 31665a3

Please sign in to comment.