gpt4 book ai didi

authentication - NetSuite SuiteTalk token 认证 : Invalid login attempt

转载 作者:行者123 更新时间:2023-12-04 17:48:43 24 4
gpt4 key购买 nike

我正在使用 Netsuite Web 服务 (SuiteTalk) api,但在使用 tokenPassport 时不断收到无效登录尝试错误。由于 token 认证看起来相当复杂,我将包括我采取的所有步骤。

我已从设置 > 集成 > Web 服务首选项中检索帐户 ID

我设置了一个新角色,所有身份验证框都未选中。
在权限>设置中,我添加了以下权限

  • 访问 token 管理 = 完整
  • 用户访问 token = 完整
  • Web 服务 = 完整

  • 我已将新角色添加到我的用户访问权限

    我在设置 > 集成 > 管理器集成中创建了一个新应用程序
    在身份验证选项卡下,我选择了基于 token 的身份验证

    我在设置 > 用户/角色 > 访问 token 中创建了一个新的访问 token ,设置如下
  • 应用程序名称 = 新应用程序
  • 用户 = 我
  • 角色 = 新角色
  • token 名称 = 重命名为有意义的内容

  • 我的请求 xml 看起来像
    <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:msg="urn:messages_2016_2.platform.webservices.netsuite.com"
    xmlns:core="urn:core_2016_2.platform.webservices.netsuite.com">
    <env:Header>
    <msg:tokenPassport>
    <core:account>123XXXX_SB1</core:account>
    <core:consumerKey>MY_CONSUMER_KEY</cre:consumerKey>
    <core:token>MY_TOKEN_ID</core:token>
    <core:nonce>ZcVszy7ySJ3Ji8PIgwlW</core:nonce>
    <core:timestamp>1530692570</core:timestamp>
    <core:signature algorithm="HMAC-SHA256">nN7V4PH9qWNT9BocMQzKcFetqZ3QxpxutDJ8iZjSmH8=</core:signature>
    </msg:tokenPassport>
    </env:Header>
    <env:Body>
    <msg:get>
    <msg:baseRef xsi:type="core:RecordRef" internalId="1234567" type="customer"/>
    </msg:get>
    </env:Body>
    </env:Envelope>

    我正在使用以下 ruby​​ 类来生成随机数和签名
    class NetSuiteToken
    attr_reader :account, :consumer_key, :consumer_secret, :token_id, :token_secret

    def initialize(account, consumer_key, consumer_secret, token_id, token_secret)
    @account = account.to_s
    @consumer_key = consumer_key
    @consumer_secret = consumer_secret
    @token_id = token_id
    @token_secret = token_secret
    end

    def passport
    {
    'msg:tokenPassport' => {
    'core:account' => account,
    'core:consumerKey' => consumer_key,
    'core:token' => token_id,
    'core:nonce' => nonce,
    'core:timestamp' => timestamp,
    'core:signature' => signature,
    :attributes! => { 'core:signature' => { 'algorithm' => 'HMAC-SHA256' } }
    }
    }
    end

    private

    def signature
    Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), signature_key, signature_data))
    end

    def signature_key
    "#{consumer_secret}&#{token_secret}"
    end

    def signature_data
    "#{account}&#{consumer_key}&#{token_id}&#{nonce}&#{timestamp}"
    end

    def nonce
    @nonce ||= Array.new(20) { alphanumerics.sample }.join
    end

    def alphanumerics
    [*'0'..'9',*'A'..'Z',*'a'..'z']
    end

    def timestamp
    @timestamp ||= Time.now.to_i
    end
    end

    如果有人可以提供任何帮助,将不胜感激。

    最佳答案

    您需要添加名为“使用访问 token 登录”的角色权限

    关于authentication - NetSuite SuiteTalk token 认证 : Invalid login attempt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51170179/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com