mirror of
https://github.com/songquanpeng/one-api.git
synced 2026-03-03 02:04:26 +08:00
Compare commits
3 Commits
main
...
85a024af3f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85a024af3f | ||
|
|
47a8d79b76 | ||
|
|
edc250a415 |
@@ -72,7 +72,7 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
|
|||||||
+ [x] [Anthropic Claude 系列模型](https://anthropic.com) (支持 AWS Claude)
|
+ [x] [Anthropic Claude 系列模型](https://anthropic.com) (支持 AWS Claude)
|
||||||
+ [x] [Google PaLM2/Gemini 系列模型](https://developers.generativeai.google)
|
+ [x] [Google PaLM2/Gemini 系列模型](https://developers.generativeai.google)
|
||||||
+ [x] [Mistral 系列模型](https://mistral.ai/)
|
+ [x] [Mistral 系列模型](https://mistral.ai/)
|
||||||
+ [x] [字节跳动豆包大模型(火山引擎)](https://www.volcengine.com/experience/ark?utm_term=202502dsinvite&ac=DSASUQY5&rc=2QXCA1VI)
|
+ [x] [字节跳动豆包大模型](https://console.volcengine.com/ark/region:ark+cn-beijing/model)
|
||||||
+ [x] [百度文心一言系列模型](https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html)
|
+ [x] [百度文心一言系列模型](https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html)
|
||||||
+ [x] [阿里通义千问系列模型](https://help.aliyun.com/document_detail/2400395.html)
|
+ [x] [阿里通义千问系列模型](https://help.aliyun.com/document_detail/2400395.html)
|
||||||
+ [x] [讯飞星火认知大模型](https://www.xfyun.cn/doc/spark/Web.html)
|
+ [x] [讯飞星火认知大模型](https://www.xfyun.cn/doc/spark/Web.html)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"strings"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -39,22 +40,18 @@ func getOidcUserInfoByCode(code string) (*OidcUser, error) {
|
|||||||
if code == "" {
|
if code == "" {
|
||||||
return nil, errors.New("无效的参数")
|
return nil, errors.New("无效的参数")
|
||||||
}
|
}
|
||||||
values := map[string]string{
|
values := url.Values{}
|
||||||
"client_id": config.OidcClientId,
|
values.Set("client_id", config.OidcClientId)
|
||||||
"client_secret": config.OidcClientSecret,
|
values.Set("client_secret", config.OidcClientSecret)
|
||||||
"code": code,
|
values.Set("code", code)
|
||||||
"grant_type": "authorization_code",
|
values.Set("grant_type", "authorization_code")
|
||||||
"redirect_uri": fmt.Sprintf("%s/oauth/oidc", config.ServerAddress),
|
values.Set("redirect_uri", fmt.Sprintf("%s/oauth/oidc", config.ServerAddress))
|
||||||
}
|
formData := values.Encode()
|
||||||
jsonData, err := json.Marshal(values)
|
req, err := http.NewRequest("POST", config.OidcTokenEndpoint, strings.NewReader(formData))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req, err := http.NewRequest("POST", config.OidcTokenEndpoint, bytes.NewBuffer(jsonData))
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
|
||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
|
|||||||
Reference in New Issue
Block a user