public static string GetUserInfo(AvansOauthHelperOptions options, OauthToken accesToken) { OAuthRequest client = OAuthRequest.ForProtectedResource("GET", options.AvansClientId, options.AvansSecret, accesToken.Token, accesToken.Secret); client.RequestUrl = "https://publicapi.avans.nl/oauth/people/@me"; // Using URL query authorization to get the request token string auth = client.GetAuthorizationQuery(); var url = client.RequestUrl + "?" + auth; var request = (HttpWebRequest)WebRequest.Create(url); var response = (HttpWebResponse)request.GetResponse(); Stream receiveStream = response.GetResponseStream(); StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8); string body = reader.ReadToEnd(); return(body); }
public static OauthToken GetAccesToken(AvansOauthHelperOptions options, OauthToken requestToken, string verifier) { // Creating a new instance with a helper method OAuthRequest client = OAuthRequest.ForAccessToken(options.AvansClientId, options.AvansSecret, requestToken.Token, requestToken.Secret); client.Verifier = verifier; client.RequestUrl = "https://publicapi.avans.nl/oauth/access_token"; // Using URL query authorization to get the request token string auth = client.GetAuthorizationQuery(); var url = client.RequestUrl + "?" + auth; var request = (HttpWebRequest)WebRequest.Create(url); var response = (HttpWebResponse)request.GetResponse(); Stream receiveStream = response.GetResponseStream(); StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8); string body = reader.ReadToEnd(); //turn body into uri var uri = "http://temp?" + body; return(AvansOauthHelper.getTokenFormUri(uri)); }