openai/openai-go

Public

mirrored from https://github.com/openai/openai-goAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
main

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

auth/error.go

37lines · modecode

1package auth
2
3import (
4 "fmt"
5
6 "github.com/openai/openai-go/v3/shared"
7)
8
9// SubjectTokenProviderError is raised when failing to get the subject token from the cloud environment.
10type SubjectTokenProviderError struct {
11 Provider string
12 Message string
13 Cause error
14}
15
16func (e *SubjectTokenProviderError) Error() string {
17 if e.Cause != nil {
18 return fmt.Sprintf("%s provider error: %s: %v", e.Provider, e.Message, e.Cause)
19 }
20 return fmt.Sprintf("%s provider error: %s", e.Provider, e.Message)
21}
22
23func (e *SubjectTokenProviderError) Unwrap() error {
24 return e.Cause
25}
26
27// OAuthError is raised when there is an error in the RFC-defined OAuth flow, such as failing to exchange the token.
28// See https://datatracker.ietf.org/doc/html/rfc8693 for the OAuth 2.0 Token Exchange specification.
29type OAuthError struct {
30 StatusCode int
31 ErrorCode shared.OAuthErrorCode
32 ErrorDescription string
33}
34
35func (e *OAuthError) Error() string {
36 return fmt.Sprintf("OAuth error (status %d): %s - %s", e.StatusCode, e.ErrorCode, e.ErrorDescription)
37}
38