private BearerToken getTwoLeggedBearerToken(Lynx.CollaborationClient.AuthTokenRequest request) { //POST https://developer.api.autodesk.com/authentication/v1/authenticate string endpoint = apigeeHostUrl + "/authentication/v1/authenticate"; Log("oauth2, get two legged bearer token, request endpoint: " + endpoint); string body = "client_id=" + request.m_clientId + "&client_secret=" + request.m_clientSecret + "&grant_type=client_credentials" + "&scope=" + Nancy.Helpers.HttpUtility.UrlEncode(request.m_scope); Log("oauth2, get two legged bearer token, request body(form url encoded): " + body); string response; using (var client = new System.Net.WebClient()) { client.Headers[System.Net.HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; response = client.UploadString(endpoint, "POST", body); } var jsonObject = Newtonsoft.Json.Linq.JObject.Parse(response); Log("oauth2, get two legged bearer token, response: " + jsonObject.ToString()); return(new BearerToken() { AccessToken = jsonObject["access_token"].Value <string>(), TokenType = jsonObject["token_type"].Value <string>(), ExpiresIn = jsonObject["expires_in"].Value <uint>() }); }
private BearerToken getTwoLeggedBearerToken(string clientId, string clientSecret, string scope) { var authTokenRequest = new Lynx.CollaborationClient.AuthTokenRequest(clientId, clientSecret, "", "", scope); return(getTwoLeggedBearerToken(authTokenRequest)); }