Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aisbf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
aisbf
Commits
bebce4e7
Commit
bebce4e7
authored
Apr 20, 2026
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Claude OAuth2 callback handling, raise version to 0.99.40
parent
156c2199
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
35 deletions
+37
-35
__init__.py
aisbf/__init__.py
+1
-1
main.py
main.py
+34
-32
pyproject.toml
pyproject.toml
+1
-1
setup.py
setup.py
+1
-1
No files found.
aisbf/__init__.py
View file @
bebce4e7
...
...
@@ -54,7 +54,7 @@ from .auth.qwen import QwenOAuth2
from
.handlers
import
RequestHandler
,
RotationHandler
,
AutoselectHandler
from
.utils
import
count_messages_tokens
,
split_messages_into_chunks
,
get_max_request_tokens_for_model
__version__
=
"0.99.
39
"
__version__
=
"0.99.
40
"
__all__
=
[
# Config
"config"
,
...
...
main.py
View file @
bebce4e7
...
...
@@ -12335,46 +12335,48 @@ async def dashboard_claude_auth_complete(request: Request):
# Import ClaudeAuth
from
aisbf.auth.claude
import
ClaudeAuth
# Create auth instance
auth
=
ClaudeAuth
()
auth
.
credentials_file
=
Path
(
credentials_file
)
.
expanduser
()
# Use the new exchange_code_for_tokens method with retry logic
# Pass state as the second parameter (required), verifier as third (optional)
success
=
auth
.
exchange_code_for_tokens
(
code
,
state
,
verifier
)
# Only the ONE config admin (user_id=None from aisbf.json) saves to file
# All other users (including database admins) save to database
current_user_id
=
request
.
session
.
get
(
'user_id'
)
is_config_admin
=
current_user_id
is
None
if
success
:
# Only the ONE config admin (user_id=None from aisbf.json) saves to file
# All other users (including database admins) save to database
current_user_id
=
request
.
session
.
get
(
'user_id'
)
is_config_admin
=
current_user_id
is
None
save_callback
=
None
if
not
is_config_admin
:
# For non-admin users, set up save_callback to save directly to database
provider_key
=
request
.
session
.
get
(
'oauth2_provider'
)
if
not
is_config_admin
:
# Non-config-admin user: save credentials to database
def
save_callback
(
creds
):
try
:
from
aisbf.database
import
get_database
db
=
DatabaseRegistry
.
get_config_database
()
provider_key
=
request
.
session
.
get
(
'oauth2_provider'
)
if
db
and
current_user_id
and
provider_key
:
# Read the credentials that were just saved to file
credentials_path
=
Path
(
credentials_file
)
.
expanduser
()
if
credentials_path
.
exists
():
with
open
(
credentials_path
,
'r'
)
as
f
:
db_credentials
=
json
.
load
(
f
)
# Save to database
db
.
save_user_oauth2_credentials
(
user_id
=
current_user_id
,
provider_id
=
provider_key
,
auth_type
=
'claude_oauth2'
,
credentials
=
db_credentials
)
logger
.
info
(
f
"ClaudeOAuth2: Saved credentials to database for user {current_user_id}"
)
# Remove the file since we're using database storage for non-admin
credentials_path
.
unlink
(
missing_ok
=
True
)
db
.
save_user_oauth2_credentials
(
user_id
=
current_user_id
,
provider_id
=
provider_key
,
auth_type
=
'claude_oauth2'
,
credentials
=
creds
)
logger
.
info
(
f
"ClaudeOAuth2: Saved credentials to database for user {current_user_id}"
)
except
Exception
as
e
:
logger
.
error
(
f
"ClaudeOAuth2: Failed to save credentials to database: {e}"
)
raise
# Create auth instance with proper save_callback
auth
=
ClaudeAuth
(
credentials_file
=
credentials_file
,
skip_initial_load
=
True
,
save_callback
=
save_callback
)
# Use the new exchange_code_for_tokens method with retry logic
# Pass state as the second parameter (required), verifier as third (optional)
success
=
await
auth
.
exchange_code_for_tokens
(
code
,
state
,
verifier
)
if
success
:
# Clear temporary file for non-admin users (it was never written when using save_callback)
if
not
is_config_admin
:
credentials_path
=
Path
(
credentials_file
)
.
expanduser
()
credentials_path
.
unlink
(
missing_ok
=
True
)
# Clear session data
request
.
session
.
pop
(
'oauth2_code'
,
None
)
...
...
pyproject.toml
View file @
bebce4e7
...
...
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name
=
"aisbf"
version
=
"0.99.
39
"
version
=
"0.99.
40
"
description
=
"AISBF - AI Service Broker Framework || AI Should Be Free - A modular proxy server for managing multiple AI provider integrations"
readme
=
"README.md"
license
=
"GPL-3.0-or-later"
...
...
setup.py
View file @
bebce4e7
...
...
@@ -49,7 +49,7 @@ class InstallCommand(_install):
setup
(
name
=
"aisbf"
,
version
=
"0.99.
39
"
,
version
=
"0.99.
40
"
,
author
=
"AISBF Contributors"
,
author_email
=
"stefy@nexlab.net"
,
description
=
"AISBF - AI Service Broker Framework || AI Should Be Free - A modular proxy server for managing multiple AI provider integrations"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment