Bluemix – 对象存储 – node.js – pkgcloud – openstack返回401

我试图使用pkgcloud(node.js)openstack与bluemix对​​象存储,但是当我把所有请求的参数作为官方页面,它总是返回401.我尝试使用邮递员所描述的bluemix和它的作品。

我创build了一个包 ,它能够授权它。 这只是pkgcloud的一个副本,有一些修复。

编辑:它正在工作! V2支持被bluemix击倒,现在只有V3的支持,但我再次find问题。

请记住使用最新版本(2.0.0)

所以这就是你现在如何使用它:

var pkgcloud = require('pkgcloud-bluemix-objectstorage'); // Create a config object var config = {}; // Specify Openstack as the provider config.provider = "openstack"; // Authentication url config.authUrl = 'https://identity.open.softlayer.com/'; config.region= 'dallas'; // Use the service catalog config.useServiceCatalog = true; // true for applications running inside Bluemix, otherwise false config.useInternal = false; // projectId as provided in your Service Credentials config.tenantId = 'xxx'; // userId as provided in your Service Credentials config.userId = 'xxx'; // username as provided in your Service Credentials config.username = 'xxx'; // password as provided in your Service Credentials config.password = 'xxx'; // This is part which is NOT in original pkgcloud. This is how it works with newest version of bluemix and pkgcloud at 22.12.2015. //In reality, anything you put in this config.auth will be send in body to server, so if you need change anything to make it work, you can. PS : Yes, these are the same credentials as you put to config before. //I do not fill this automatically to make it transparent. config.auth = { forceUri : "https://identity.open.softlayer.com/v3/auth/tokens", //force uri to v3, usually you take the baseurl for authentication and add this to it /v3/auth/tokens (at least in bluemix) interfaceName : "public", //use public for apps outside bluemix and internal for apps inside bluemix. There is also admin interface, I personally do not know, what it is for. "identity": { "methods": [ "password" ], "password": { "user": { "id": "***", //userId "password": "***" //userPassword } } }, "scope": { "project": { "id": "***" //projectId } } }; console.log("config: " + JSON.stringify(config)); // Create a pkgcloud storage client var storageClient = pkgcloud.storage.createClient(config); // Authenticate to OpenStack storageClient.auth(function (error) { if (error) { console.error("storageClient.auth() : error creating storage client: ", error); } else { // Print the identity object which contains your Keystone token. console.log("storageClient.auth() : created storage client: " + JSON.stringify(storageClient._identity)); } }); 

PS:你应该能够在bluemix之外连接到这个服务,因此你可以在你的本地主机上testing它。


下面的行是针对版本1.2.3的旧内容的,仅当您要使用2016年1月之前与bluemix一起使用的pkgcloud的v2版本

编辑:它看起来像bluemixclosuresV2的OpenStack的支持,只支持v3,这是不支持的pkgcloud。 所以这不起作用了(至less对我来说)。


问题实际上是在pkgcloud和bluemix授权过程之间。 Bluemix正在期待一个不同的授权。 我创build了一个包 ,它能够授权它。 这只是pkgcloud的一个副本,有一些修复。

这就是你如何使用它:

 var pkgcloud = require('pkgcloud-bluemix-objectstorage'); // Create a config object var config = {}; // Specify Openstack as the provider config.provider = "openstack"; // Authentication url config.authUrl = 'https://identity.open.softlayer.com/'; config.region= 'dallas'; // Use the service catalog config.useServiceCatalog = true; // true for applications running inside Bluemix, otherwise false config.useInternal = false; // projectId as provided in your Service Credentials config.tenantId = 'xxx'; // userId as provided in your Service Credentials config.userId = 'xxx'; // username as provided in your Service Credentials config.username = 'xxx'; // password as provided in your Service Credentials config.password = 'xxx'; // This is part which is NOT in original pkgcloud. This is how it works with newest version of bluemix and pkgcloud at 22.12.2015. //In reality, anything you put in this config.auth will be send in body to server, so if you need change anything to make it work, you can. PS : Yes, these are the same credentials as you put to config before. //I do not fill this automatically to make it transparent. config.auth = { tenantId: "xxx", //projectId passwordCredentials: { userId: "xxx", //userId password: "xxx" //password } }; console.log("config: " + JSON.stringify(config)); // Create a pkgcloud storage client var storageClient = pkgcloud.storage.createClient(config); // Authenticate to OpenStack storageClient.auth(function (error) { if (error) { console.error("storageClient.auth() : error creating storage client: ", error); } else { // Print the identity object which contains your Keystone token. console.log("storageClient.auth() : created storage client: " + JSON.stringify(storageClient._identity)); } });