Exemple #1
0
        public async Task <IRestResponse> GetUsers(string accountId)
        {
            TwoLeggedApi oauth  = new TwoLeggedApi();
            dynamic      bearer = await oauth.AuthenticateAsync(Credentials.GetAppSetting("FORGE_CLIENT_ID"), Credentials.GetAppSetting("FORGE_CLIENT_SECRET"), "client_credentials", new Scope[] { Scope.AccountRead });

            RestClient  client  = new RestClient(BASE_URL);
            RestRequest request = new RestRequest("/hq/v1/accounts/{account_id}/users", RestSharp.Method.GET);

            request.AddParameter("account_id", accountId.Replace("b.", string.Empty), ParameterType.UrlSegment);
            request.AddHeader("Authorization", "Bearer " + bearer.access_token);
            return(await client.ExecuteTaskAsync(request));
        }
Exemple #2
0
        public string GetOAuthURL()
        {
            // prepare the sign in URL
            Scope[]        scopes          = { Scope.DataRead };
            ThreeLeggedApi _threeLeggedApi = new ThreeLeggedApi();
            string         oauthUrl        = _threeLeggedApi.Authorize(
                Credentials.GetAppSetting("FORGE_CLIENT_ID"),
                oAuthConstants.CODE,
                Credentials.GetAppSetting("FORGE_CALLBACK_URL"),
                new Scope[] { Scope.DataRead, Scope.DataCreate, Scope.DataWrite, Scope.ViewablesRead });

            return(oauthUrl);
        }
Exemple #3
0
 [Route("api/forge/clientid")] // see Web.Config FORGE_CALLBACK_URL variable
 public dynamic GetClientID()
 {
     return(new { id = Credentials.GetAppSetting("FORGE_CLIENT_ID") });
 }