Unauthorized error while connecting Object Storage from API from Postman

你离开我真会死。 提交于 2019-12-02 05:48:54

问题


I am trying to get object storage container details using provided API in post man But I am getting Unauthorized error,

API information available at http://developer.openstack.org/api-ref/object-storage/index.html?expanded=get-object-content-and-metadata-detail,show-account-details-and-list-containers-detail#accounts

Following details I am set in PostMan,

Method Get

Url: https://{domain}.objectstorage.softlayer.net/auth/v1.0/{userid}?format=json

Header: Key: X-Auth-Token Value: {token}

Error got in response of PostMan,

<html>
    <h1>Unauthorized</h1>
    <p>This server could not verify that you are authorized to access the document you requested.</p>
</html>

回答1:


To retrieve containers from Object Storage using Postman, follow these steps:

1. We need to generate the token to access Object Storage

You need to get credentials from your object storage, so you can go to:

Control Portal >> Object Storage >> Select Account Name (e.g. SLOS123123-10) >> Select Cluster (e.g. Milan 1) >> click on "View Credentials"

You will be able to see

  • "Authentication Endpoint (public and private)"
  • "username"
  • "API Key (Password)"

Then, you can go to postman and fill as the below example:

As you see, I had success with the request. So I need the "Headers" information from the response, as the follow example:

2. Retrieve containers

After getting "X-Storage-Url" and "X-Storage-Token", you can retrieve the containers as the example below:

I hope it helps you to access Object Storage using Postman, please let me know any doubt or comment.




回答2:


Are you using your SoftLayer username or the Object Storage username? To get your Object Storage credentials go to https://control.softlayer.com/storage/objectstorage > Click on your Object Storage Username and on the following page click View Credentials.

Get the Token curl -i -H "X-Auth-Key: [insert API Key here]" -H "X-Auth-User: [insert Object Storage Username here]" [insert Authentication Endpoint here]

Once you have the Token you can perform basic operations

List Containers curl -i -H 'X-Auth-Token: [X-Auth-Token from Authentication step]' [X-Storage-Url from Authentication step]

View Objects in a Container curl -i -H "X-Auth-Token: [X-Auth-Token from Authentication step]" [X-Storage-Url from Authentication step]/[container name]




回答3:


To start, the error that you're receiving is because the userid parameter in your request is not correct. The X-Storage-Url should be placed in that position.

To retrieve the containers you first need a X-Auth-Token and a X-Storage-Url. For this you could run the next curl command:

curl -i -H "X-Auth-User: ACC-278436-15:USERNAME " -H "X-Auth-Key: API_KEY " https://dal05.objectstorage.softlayer.net/auth/v1.0

ACC-278436-15: The object storage username retrieved from SoftLayer_Account::getHubNetworkStorage method

USERNAME: The username used in Control portal which is the same used in the REST request that calls the SoftLayer_Account::getHubNetworkStorage method

API_KEY: The apikey used in the REST request that calls the SoftLayer_Account::getHubNetworkStorage method

The result will be similar to this:

• X-Auth-Token: AUTH_tkb26239d441d6401d9482b004d45f7259 – the token we need

• X-Storage-Url: https://dal05.objectstorage.softlayer.net/v1/AUTH_df0de35c-d00a-40aa-b697-2b7f1b9331a6 - the URL to access the storage

Now place these values in this way:

Here's a good link on how to manage SoftLayer Object Storage through rest API https://sldn.softlayer.com/blog/waelriac/managing-softlayer-object-storage-through-rest-apis



来源:https://stackoverflow.com/questions/40319729/unauthorized-error-while-connecting-object-storage-from-api-from-postman

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!