Forum Xamarin.Forms

How to fetch data from restapi with authentication key

Authentication key are consumer key,Consumer Secret,Access Token,Token Secret



  • AlfonsiAlfonsi USMember ✭✭✭

    This is not a question

  • NajilathNajilath Member ✭✭

    how to fetch data from restapi by passing authentication key

  • LeonLuLeonLu Member, Xamarin Team Xamurai
    edited August 2019

    Do you want to get the users' information from the request header?

  • NajilathNajilath Member ✭✭
    OAuthRequest client = OAuthRequest.ForClientAuthentication("Consumer Key", "Consumer Secret", "Access Token", "Token Secret");
            client.RequestUrl = "https://.......";
            string auth = client.GetAuthorizationHeader();
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(client.RequestUrl);
             request.Headers.Add ("Authorization", auth);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

    Exception:System.Net.WebException: 'The remote server returned an error: (401) UNAUTHORIZED.'
    How to sole the problem

Sign In or Register to comment.