mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
feat: add pkce
This commit is contained in:
@@ -1273,6 +1273,33 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
return cacheDir
|
||||
}
|
||||
|
||||
async handleGlamaCallback(code: string) {
|
||||
let apiKey: string
|
||||
try {
|
||||
const response = await axios.post("https://glama.ai/api/gateway/v1/auth/exchange-code", { code })
|
||||
if (response.data && response.data.apiKey) {
|
||||
apiKey = response.data.apiKey
|
||||
} else {
|
||||
throw new Error("Invalid response from Glama API")
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error exchanging code for API key:", error)
|
||||
throw error
|
||||
}
|
||||
|
||||
const glama: ApiProvider = "glama"
|
||||
await this.updateGlobalState("apiProvider", glama)
|
||||
await this.storeSecret("glamaApiKey", apiKey)
|
||||
await this.postStateToWebview()
|
||||
if (this.cline) {
|
||||
this.cline.api = buildApiHandler({
|
||||
apiProvider: glama,
|
||||
glamaApiKey: apiKey,
|
||||
})
|
||||
}
|
||||
// await this.postMessageToWebview({ type: "action", action: "settingsButtonClicked" }) // bad ux if user is on welcome
|
||||
}
|
||||
|
||||
async readGlamaModels(): Promise<Record<string, ModelInfo> | undefined> {
|
||||
const glamaModelsFilePath = path.join(
|
||||
await this.ensureCacheDirectoryExists(),
|
||||
|
||||
Reference in New Issue
Block a user