Skip to content
Open
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
9 changes: 5 additions & 4 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ async function exchange(code, verifier) {
const result = await fetch("https://console.anthropic.com/v1/oauth/token", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
body: JSON.stringify({
body: new URLSearchParams({
code: splits[0],
state: splits[1],
grant_type: "authorization_code",
Expand Down Expand Up @@ -74,6 +74,7 @@ export async function AnthropicAuthPlugin({ client }) {
provider: "anthropic",
async loader(getAuth, provider) {
const auth = await getAuth();
if (!auth) return {};
if (auth.type === "oauth") {
// zero out cost for max plan
for (const model of Object.values(provider.models)) {
Expand Down Expand Up @@ -101,9 +102,9 @@ export async function AnthropicAuthPlugin({ client }) {
{
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
body: JSON.stringify({
body: new URLSearchParams({
grant_type: "refresh_token",
refresh_token: auth.refresh,
client_id: CLIENT_ID,
Expand Down