Skip to content

fix(auth): support string interval in OpenAI device-code flow#56

Merged
lxowalle merged 1 commit intosipeed:mainfrom
jmahotiedu:fix/openai-device-code-interval
Feb 12, 2026
Merged

fix(auth): support string interval in OpenAI device-code flow#56
lxowalle merged 1 commit intosipeed:mainfrom
jmahotiedu:fix/openai-device-code-interval

Conversation

@jmahotiedu
Copy link
Contributor

Summary

  • fix OpenAI device-code login parsing when interval is returned as a string (e.g. 5)
  • keep support for numeric interval values
  • add auth tests for numeric/string/invalid interval payloads
  • print the browser auth URL before waiting and include a headless fallback hint

Why

picoclaw auth login --provider openai --device-code currently fails with:
json: cannot unmarshal string into Go struct field .interval of type int

OpenAI's device auth endpoint returns interval as a string in practice, so unmarshalling into int breaks login.

Changes

  • add parseDeviceCodeResponse and parseFlexibleInt in pkg/auth/oauth.go
  • switch LoginDeviceCode to use the flexible parser
  • add:
    • TestParseDeviceCodeResponseIntervalAsNumber
    • TestParseDeviceCodeResponseIntervalAsString
    • TestParseDeviceCodeResponseInvalidInterval

Validation

  • go test ./pkg/auth -run Test(ParseDeviceCodeResponse|BuildAuthorizeURL)

Related

planned-date: 2026-02-12

why: Device-code login was failing because the interval field can arrive as a quoted number, which breaks strict integer decoding and blocks login in shell-only environments.

what: Added flexible interval parsing for numeric or quoted values, wired LoginDeviceCode to the parser, printed the browser auth URL before waiting, and added parser tests for numeric, quoted, and invalid interval payloads.

verification: c:\projects\toolchains\go\bin\go.exe test ./pkg/auth -run Test(ParseDeviceCodeResponse|BuildAuthorizeURL)
@lxowalle
Copy link
Collaborator

Thanks for the pr

@Zepan
Copy link
Contributor

Zepan commented Feb 13, 2026

Thanks for your contribution! We are forming the PicoClaw Dev Group to accelerate the evolution of the project. Any developer with more than one merged PR is invited to join.

Would you like to join the PicoClaw Dev Group? If so, please send an email to support@sipeed.com with the subject line: [Join PicoClaw Dev Group] + Your GitHub account. We will send the Discord invite link to your inbox.

emadomedher pushed a commit to emadomedher/picoclaw that referenced this pull request Feb 17, 2026
…nterval

fix(auth): support string interval in OpenAI device-code flow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth either tries to invoke the browser or fails on deserializing response on device-code

3 participants