有赞新零售社区

发帖
API使用问题»API调用于GPT时Authentication配置问题

[API调用-商品/交易] API调用于GPT时Authentication配置问题

花小生 02-20 765 浏览 5 评论 | 只看楼主 [打印]  关闭
想要用CHATGPT GPTS中的ACTION功能调用有赞API实现一些同步查询功能,在ACTION Authentication具体设置中遇到一些问题(已经获取了ACCESS TOKEN及相关类目授权)

根据文档Authentication Type授权方式选择了OAuth
其他要求项——
Client ID:有Client Secret:有
Authorization URL:不知道填什么,填了和Token URL一样的发现返回有误
Token URL:有
Scope
Token Exchange Method:Default (POST request)



用手机打开
收藏 ··· 回复
    您好,您参考的文档麻烦提供下哈

    您好,您是要接入这个API接口对吧,可以参考下该文档https://doc.youzanyun.com/resource/doc/7513
    • 花小生 02-21
      老师这个链接也有参考过的,其中也没有直接指明Authorization URL应该是什么。
      这边是希望在CHATGPT里面调用有赞API,出现了以下几种情况:
      1.虽然已经获得了ACCESS TOKEN,但把这个作为API KEY来调用总是说TOKEN不存在之类;
      2.更换授权成Oauth模式,就需要提供一个登录的页面Authorization URL,试了好几个都不对;
      3.如果通过第三方集成,比如集简云自定义有赞API为一个应用,格式上倒是对了也能连通调用,但是查询结果总是报错(以 单品详情查询为例,无论商品ID,品名等等,都告知没有这个可查询项目)

      不知道这个是不是跟CODE有关系,似乎文档里面提到了CODE获取,但我是自用无容器...

    您好,1,调用有赞云接口获取token不存在报错,可以参考https://doc.youzanyun.com/resource/doc/3389/3389文档进行排查下
    2自用型应用,是不需要 code的,authorize_type固定填silent,可参考文档获取token:https://doc.youzanyun.com/resource/develop-guide/41355/41510。

    3辛苦提供一下这次调用接口返回给你的traceID(traceID是会在你调用接口会返回给你的一个字段,关于traceID你还可以参考文档:API日志排查工具:https://doc.youzanyun.com/doc#/content/27027/39835/51209)
    或者补充一下调用接口时使用的access_token值+接口名称(包括版本号)+具体调用时间+请求参数值。方便精准获取日志解决问题。
    4,你的应用ID麻烦提供下
    • 花小生 02-21
      App Id:
      10003955
      其他的我查看一下
    • 花小生 02-22
      调用 open.youzanyun.com API 获取商品详情时失败,原因是请求凭证无效。收到的错误代码为 4201,表示“非法的请求凭证”。请确认所使用的API请求凭证是正确的,然后重试。
    • 千寻 回复 花小生 02-22
      您好,参考https://doc.youzanyun.com/resource/doc/3027/3027文档排查下哈,若排查后还有问题,提供下调用接口返回给你的traceID
    • 花小生 回复 千寻 02-22
      4201        非法的请求凭证        1、获取 token,请求入参中,token 为空字符串等。
      2、已经获取过了 token,token 鉴权不通过(店铺和应用的授权关系过期,或者店铺关闭授权)。        按照正确的方式,重新 获取 token,请求接口时传入正确的 token 信息。

      找到了我这个的问题和解决 但是 token是对的呢...
    • 千寻 回复 花小生 02-22
      辛苦提供一下这次调用接口返回给你的traceID(traceID是会在你调用接口会返回给你的一个字段,关于traceID你还可以参考文档:API日志排查工具:https://doc.youzanyun.com/doc#/content/27027/39835/51209)
      或者补充一下调用接口时使用的access_token值+接口名称(包括版本号)+具体调用时间+请求参数值。方便精准获取日志解决问题。
    • 花小生 回复 千寻 02-23
      最新一次的操作显示
      查询时遇到了问题:“非法的请求凭证”。请检查您的API凭证是否正确配置,然后再次尝试。
      但是在traceID这边并没有刷新。。
    • 千寻 回复 花小生 02-23
      您好,很抱歉,根据现在的信息,这边查看日志,没有看到该报错信息,您这边使用的access_token值+接口名称(包括版本号)+具体调用时间+请求参数值提供下。方便精准获取日志解决问题。
    • 花小生 回复 千寻 02-23
      access_token=b34884c0cb15bc8749ea1de9db3356b
      接口URL=https://open.youzanyun.com/api/youzan.item.get/3.0.0
      最后一次调用时间2/22 18:00左右
      完整调用代码——
      openapi: 3.0.0
      info:
        title: Youzan API
        description: API for querying single item details from Youzan.
        version: 1.0.0
      servers:
        - url: https://open.youzanyun.com/api/youzan.item.get/3.0.0
          description: Youzan API server
      paths:
        /:
          get:
            operationId: getItemDetails
            summary: Query single item details from Youzan API.
            description: Retrieves details for a single item from Youzan API, supporting various parameters for flexible queries.
            parameters:
              - name: item_id
                in: query
                schema:
                  type: string
                description: The item ID. Can get it from interfaces like youzan.items.onsale.get.
                required: false
              - name: alias
                in: query
                schema:
                  type: string
                description: The item alias. item_id and alias are mutually exclusive.
                required: false
              - name: node_kdt_id
                in: query
                schema:
                  type: integer
                description: Used only for Youzan chain stores.
                required: false
              - name: node_item_id
                in: query
                schema:
                  type: integer
                description: Item ID for Youzan chain stores. Use either this or item_id.
                required: false
              - name: use_cache
                in: query
                schema:
                  type: boolean
                  default: true
                description: Whether to use cache. Defaults to True.
                required: false
            responses:
              "200":
                description: Successful response with item details.
                content:
                  application/json:
                    schema:
                      $ref: "#/components/schemas/ItemResponse"
              default:
                description: Unexpected error
                content:
                  application/json:
                    schema:
                      type: object
                      properties:
                        error:
                          type: string
                          description: Error message if the request fails.
                        status_code:
                          type: integer
                          description: HTTP status code of the error response.
      security:
        - bearerAuth: []
      components:
        securitySchemes:
          bearerAuth:
            type: http
            scheme: bearer
            bearerFormat: JWT
        schemas:
          ItemResponse:
            type: object
            properties:
              trace_id:
                type: string
              code:
                type: integer
              data:
                type: object
                properties:
                  item:
                    $ref: "#/components/schemas/ItemData"
          ItemData:
            type: object
            properties:
              hide_stock:
                type: integer
                description: 库存是否隐藏
              virtual_extend:
                type: object
                properties:
                  effective_type:
                    type: integer
                    description: 虚拟扩展的有效类型
              buy_quota:
                type: integer
                description: 购买限额
              item_type:
                type: integer
                description: 商品类型
              num:
                type: integer
                description: 商品数量
              purchase_right:
                type: boolean
                description: 购买权利
              price:
                type: integer
                description: 商品价格
              sku_images:
                type: array
                items:
                  type: string
                description: 商品SKU图片
              post_type:
                type: integer
                description: 帖子类型
              barcode:
                type: string
                description: 商品条码
              need_customs_check:
                type: boolean
                description: 是否需要海关检查
              tag_ids:
                type: array
                items:
                  type: integer
                description: 标签ID数组
              item_tags:
                type: array
                items:
                  $ref: "#/components/schemas/ItemTag"
              created:
                type: string
                format: date-time
                description: 创建时间
              is_listing:
                type: boolean
                description: 是否上架
              stock_deduct_mode:
                type: integer
                description: 库存扣减模式
          ItemTag:
            type: object
            properties:
              created:
                type: string
                format: date-time
                description: 标签创建时间
              share_url:
                type: string
                description: 分享URL
              name:
                type: string
                description: 标签名称
    加载更多

    您好,查看日志,该接口目前只有两条请求,没有2/22 18:00左右的请求日志,2024-02-22 00:31:29请求是成功的,2024-02-22 00:31:02请求的时候是没有添加白名单的,没有您说的非法的请求凭证,
    您看下您报错的非法的请求凭证是不是把access_token作为入参传入了,access_token需要拼接在API后面,不能作为入参传入


    您好,该请求参数异常, 您传的都是string  参考文档传入正确的类型。
    有赞云API接口请求方式:POST,您传的是get,access_token也当作参数传入了https://doc.youzanyun.com/detail/API/0/45
    {
    "access_token": "b34884c0cb15bc8749ea1de9db3356b",
    "node_kdt_id": "",
    "q": "",
    "item_source": "0",
    "channel": "0",
    "offline_id": "",
    "tag_id": "",
    "order_by": "sold_num:desc",
    "page_no": "1",
    "update_time_start": "",
    "page_size": "20",
    "update_time_end": ""
    },
    • 花小生 02-24
      1.
      TYPE按照文档的更正以后出现这个——
      对于您提供的YouZan Items Onsale API的OpenAPI规范,我已经进行了必要的修改,以确保其符合OpenAPI 3.0标准,并且将Java特定的数据类型转换为JSON schema兼容的类型。在OpenAPI中,数据类型应该使用JSON schema规范描述(例如string、integer、boolean、object、array),而不是Java类名。

      2.TYPE外其他修正以后还是——
      目前无法通过有赞云API获取到关于“YSL圣罗兰小金条”的商品信息,可能是因为网络问题或者API服务暂时不可用。您可以稍后再试,或者直接访问有赞云的相关页面查看商品信息。如果有其他需求或问题,欢迎随时告诉我!

      3.
      有赞有没有可能像其他平台一样直接出一个内置GPTS的OPENAI规范代码...
    • 千寻 回复 花小生 02-26
      您好,无法获取商品信息的trace_id提供下,您在postman上测试是否可以呢,这边测试接口都是正常的
    • 花小生 回复 千寻 02-27
      感谢老师,这个问题已经找到办法解决了 是ACCESS TOKEN传递上出的问题,修改了直接挂在HTTP头部就OK了
    • 千寻 回复 花小生 02-27
      好的,帖子暂时置为完结状态,如果问题未解决,可以继续追问,如果有新的问题咨询,可以重新提交帖子,感谢您的理解与支持。

    1跳至
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    复制链接
    新浪微博
    QQ空间
    微信扫码
    • 回复

    • 评分

    客服工作时间是9:00-18:00,客服妹子当前不在线,若不能及时回复请谅解。试试右上角的搜索吧,论坛有丰富的经验贴、公告贴,相信一定能够帮到您~

    复制成功