Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-9187

[fiware-stackoverflow] How do I get token from fiware lab to access context broker placed behind PeP proxy?

    Details

      Description

      Created question in FIWARE Q/A platform on 09-09-2015 at 17:09
      Please, ANSWER this question AT https://stackoverflow.com/questions/32483552/how-do-i-get-token-from-fiware-lab-to-access-context-broker-placed-behind-pep-pr

      Question:
      How do I get token from fiware lab to access context broker placed behind PeP proxy?

      Description:
      I tried to use the logic of this curl command:

      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}

      to write the request in 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); }

      But I get the following error:

      When I tried doing this solution in localhost, like in the post here it works without a problem. Could it have anything to do with the fact that I registered the app under localhost:1307 in the lab account?

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-24 06:05|CREATED monitor | # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-24 06:05|CREATED monitor | # answers= 1, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-24 09:05|UPDATED status: transition Answer| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-24 09:05|UPDATED status: transition Answer| # answers= 1, accepted answer= True
        Hide
        backlogmanager Backlog Manager added a comment -

        2017-05-24 12:05|UPDATED status: transition Answered| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2017-05-24 12:05|UPDATED status: transition Answered| # answers= 1, accepted answer= True

          People

          • Assignee:
            backlogmanager Backlog Manager
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: