Skip to content

old sk api keys can't be generated anymore #32

@emboha

Description

@emboha

Describe the problem
Since April 2024, new OpenAI accounts receive project secret keys that start with sk-proj-.
When I enter such a key in WristAssist 3.2.5 the app always returns: invalid_api_key

Current source (network/src/main/java/net/devemperor/wristassist/repository/NetworkRepository.kt) only sets the Authorization header, so the backend rejects the request.

Proposed fix
Add the missing header for project keys, e.g.:

val request = original.newBuilder()
    .header("Authorization", "Bearer $apiKey")
    .apply {
        if (apiKey.startsWith("sk-proj-")) {
            header("OpenAI-Project", projectId)   // projectId can be stored next to the key in prefs
        }
    }
    .build()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions