JSON::ParserError 异常:757:'Token scope not set. This request does not have the required privilege.' 处的意外标记
JSON::ParserError Exception: 757: unexpected token at 'Token scope not set. This request does not have the required privilege.'
我正在 Rails 上使用 adn_viewer gem (https://github.com/GetSomeRest/adn_viewer) 将 Autodesk 与 Ruby 集成。使用以下代码创建存储桶时:
Adn_Viewer.create_bucket(token, name, policy)
adn_viewer.rb中的函数定义如下:
def self.create_bucket(token, name, policy)
url = URI("https://developer.api.autodesk.com/oss/v1/buckets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer ' + token
request.body = "{\"bucketKey\":\"" + name + "\",\"policy\":\"" + policy + "\"}"
JSON.parse(http.request(request).read_body)
end
我得到的错误是:
JSON::ParserError Exception: 757: unexpected token at 'Token scope not set. This request does not have the required privilege.'
此示例已过时且未维护,去年生成的 Ruby 包也未维护。
我们即将发布一个新的包和示例,以匹配去年 6 月正式发布的 API 的最新状态。同时,您至少需要为此 API 添加 bucket:create 范围作为文档:https://developer.autodesk.com/en/docs/oauth/v2/overview/scopes/ and here: https://developer.autodesk.com/en/docs/data/v2/reference/http/buckets-POST/
使用您需要的适当范围更改身份验证调用。通常data:readdata:writedata:updatebucket:readbucket:createbucket:update
更改此行:https://github.com/GetSomeRest/adn_viewer/blob/master/lib/adn_viewer.rb#L9
和:
JSON.parse(CurbFu.post({:host => 'developer.api.autodesk.com', :path => '/authentication/v1/authenticate', :protocol => "https"}, { :client_id => key, :client_secret => secret, :grant_type => 'client_credentials', :scope=> 'put your scopes here' }).body)
希望对您有所帮助,
我正在 Rails 上使用 adn_viewer gem (https://github.com/GetSomeRest/adn_viewer) 将 Autodesk 与 Ruby 集成。使用以下代码创建存储桶时:
Adn_Viewer.create_bucket(token, name, policy)
adn_viewer.rb中的函数定义如下:
def self.create_bucket(token, name, policy)
url = URI("https://developer.api.autodesk.com/oss/v1/buckets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer ' + token
request.body = "{\"bucketKey\":\"" + name + "\",\"policy\":\"" + policy + "\"}"
JSON.parse(http.request(request).read_body)
end
我得到的错误是:
JSON::ParserError Exception: 757: unexpected token at 'Token scope not set. This request does not have the required privilege.'
此示例已过时且未维护,去年生成的 Ruby 包也未维护。 我们即将发布一个新的包和示例,以匹配去年 6 月正式发布的 API 的最新状态。同时,您至少需要为此 API 添加 bucket:create 范围作为文档:https://developer.autodesk.com/en/docs/oauth/v2/overview/scopes/ and here: https://developer.autodesk.com/en/docs/data/v2/reference/http/buckets-POST/
使用您需要的适当范围更改身份验证调用。通常data:readdata:writedata:updatebucket:readbucket:createbucket:update
更改此行:https://github.com/GetSomeRest/adn_viewer/blob/master/lib/adn_viewer.rb#L9
和:
JSON.parse(CurbFu.post({:host => 'developer.api.autodesk.com', :path => '/authentication/v1/authenticate', :protocol => "https"}, { :client_id => key, :client_secret => secret, :grant_type => 'client_credentials', :scope=> 'put your scopes here' }).body)
希望对您有所帮助,