如何从fiware lab获取令牌以访问位于PeP代理后面的上下文代理?

时间:2015-09-09 15:24:09

标签: fiware fiware-orion

我尝试使用此curl命令的逻辑:

curl -s --insecure -i --header ${AUTH_BASIC} --header ${CONTENT_TYPE} -X POST https://idm/oauth2/token -d ${DATA}"
    XAUTH_TOKEN="$(eval ${REQUEST} | grep -Po '(?<="access_token": ")[^"]*')"
    echo "X-Auth-Token for '${_user}': ${XAUTH_TOKEN}

在c#中写入请求:

//GETTING TOKEN...
            String input2 = "'grant_type=password&username=<MyUsername on Lab .fiware.org&password=<myPassword>&client_id=<myClientID>&client_secret=<myClientSecret>'";
            var httpWebRequest2 = (HttpWebRequest)WebRequest.Create("https://account.lab.fiware.org/oauth2/token");
            httpWebRequest2.ContentType = "application/x-www-form-urlencoded";
            //httpWebRequest2.Accept = "application/json";
            string authInfo = "0555996e09f340d08a4baa8fff94f8c4" + ":" + "a62333f7045b4ab797669c28f9d26d30";
            authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
            httpWebRequest2.Headers["Authorization"] = "Basic " + authInfo;
            httpWebRequest2.Method = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest2.GetRequestStream()))
            {
                streamWriter.Write(input2);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse2 = (HttpWebResponse)httpWebRequest2.GetResponse();
            using (var streamReader = new StreamReader(httpResponse2.GetResponseStream()))
            {
                string result = streamReader.ReadToEnd();
                Console.WriteLine(result);
            }

但是我收到以下错误:

enter image description here

当我尝试在localhost中执行此解决方案时,就像在post here中一样,它可以正常工作。它可能与我在实验室帐户中的localhost:1307下注册应用程序这一事实有关吗?

0 个答案:

没有答案