Skip to content
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

Update bearer to Bearer #2576

Merged
merged 6 commits into from
Jun 13, 2024
Merged
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
2 changes: 1 addition & 1 deletion packages/rlc-common/src/buildClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export function getClientFactoryBody(
client.pipeline.addPolicy({
name: "customKeyCredentialPolicy",
async sendRequest(request, next) {
request.headers.set("Authorization", "bearer " + credentials.key);
request.headers.set("Authorization", "Bearer " + credentials.key);
return next(request);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function createClient(
client.pipeline.addPolicy({
name: "customKeyCredentialPolicy",
async sendRequest(request, next) {
request.headers.set("Authorization", "bearer " + credentials.key);
request.headers.set("Authorization", "Bearer " + credentials.key);
return next(request);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function createClient(
client.pipeline.addPolicy({
name: "customKeyCredentialPolicy",
async sendRequest(request, next) {
request.headers.set("Authorization", "bearer " + credentials.key);
request.headers.set("Authorization", "Bearer " + credentials.key);
return next(request);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function createClient(
client.pipeline.addPolicy({
name: "customKeyCredentialPolicy",
async sendRequest(request, next) {
request.headers.set("Authorization", "bearer " + credentials.key);
request.headers.set("Authorization", "Bearer " + credentials.key);
return next(request);
},
});
Expand Down
9 changes: 8 additions & 1 deletion packages/typespec-ts/src/transform/transfromRLCOptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
pascalCase,
NameType,
normalizeName,
PackageDetails,
Expand Down Expand Up @@ -106,7 +107,13 @@ function processAuth(program: Program) {
case "http":
securityInfo.addCredentials = true;
securityInfo.customHttpAuthHeaderName = "Authorization";
securityInfo.customHttpAuthSharedKeyPrefix = auth.scheme;
// If it is basic or bearer auth we should generate it as Basic or Bearer
securityInfo.customHttpAuthSharedKeyPrefix = [
"basic",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do we set Basic now?

Copy link
Member Author

@MaryGao MaryGao Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be the same as bearer in header.

https://swagger.io/docs/specification/authentication/basic-authentication/

Authorization: Basic ZGVtbzpwQDU1dzByZA==

Bearer

https://swagger.io/docs/specification/authentication/bearer-authentication/

Authorization: Bearer <token>

"bearer"
].includes(auth.scheme.toLowerCase())
? pascalCase(auth.scheme)
: auth.scheme;
break;
case "apiKey":
if (auth.in === "cookie") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ describe("Client Factory generation", () => {
client.pipeline.addPolicy({
name: "customKeyCredentialPolicy",
async sendRequest(request, next) {
request.headers.set("Authorization", "bearer " + credentials.key);
request.headers.set("Authorization", "Bearer " + credentials.key);
return next(request);
},
});
Expand Down
Loading