Вопрос

Does anyone have experience of authorization in Cloud Foundry v2 API using simple REST requests?

The actual docs on CF v2 API show how to login using Ruby Gem called CF :

cf login myuser --password mypwd

Also there is a NPM Package for Node JS called VMCJS on github but seems that it works only with previous version of CF API v1.

  • How can i login in CF using only HTTP request sent from e.g. Node JS?
  • Is it possible to login in CF using access token retrieved from any other UAA authorization?
Это было полезно?

Решение

Use the -t option with cf to see the HTTP request for a login:

request: post http://login.myip.xip.io/oauth/token

headers: {"content-type"=>"application/x-www-form-urlencoded;charset=utf-8", "accept"=>"application/json;charset=utf-8", "authorization"=>"Basic Y2Y6"}

body: grant_type=password&username=myuser&password=mypwd

I'm not sure I understand the second question. You login with a user/pwd and get the access token, then send that token with subsequent requests.

Другие советы

Actually, CF command line tool interact with Cloud foundry by means of accessing Cloud controller REST APIs.
Lately Cloud foundry only provide Java and Ruby client libraries for accessing Cloud Controller REST APIs. Please refer to official Cloud controller API and libraries.
However, if you would like to use Node.js to access REST APIs you have to implements interfaces all by yourself.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top