Example #1
0
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            var authApi = new ThreeLeggedApi();
            var urlPath = authApi.Authorize(tbxClientId.Text, "code", tbxCallbackUrl.Text, logInInfo.scopes);

            //webBrowser.Url = new Uri(urlPath);
            webBrowser.Load(urlPath);
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ThreeLeggedApi oAuth3legged = new ThreeLeggedApi();
            string         oauthUrl     = oAuth3legged.Authorize(
                ConfigVariables.FORGE_CLIENT_ID,
                oAuthConstants.CODE,
                ConfigVariables.FORGE_CALLBACK_URL,
                new Scope[] { Scope.DataRead },
                Page.Request.QueryString["localId"]);

            Response.Redirect(oauthUrl);
        }
Example #3
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);
        }
        public string GetOAuthURL()
        {
            Scope[]        scopes          = { Scope.DataRead };
            ThreeLeggedApi _threeLeggedApi = new ThreeLeggedApi();
            string         oauthUrl        = _threeLeggedApi.Authorize(
                Startup.Configuration["ForgeAPIID:FORGE_CLIENT_ID"],
                oAuthConstants.CODE,
                Startup.Configuration["ForgeAPIID:FORGE_CALLBACK_URL"],
                new Scope[] { Scope.DataRead, Scope.ViewablesRead }
                );

            // string url=Uri.EscapeDataString(oauthUrl);
            string url = Uri.UnescapeDataString(oauthUrl);

            return(oauthUrl);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsForgeAuthorized)
            {
                // redirect to Autodesk Accounts Sign-in page
                ThreeLeggedApi _threeLeggedApi = new ThreeLeggedApi();
                string         oauthUrl        = _threeLeggedApi.Authorize(
                    ConfigVariables.FORGE_CLIENT_ID,
                    oAuthConstants.CODE,
                    ConfigVariables.FORGE_CALLBACK_URL,
                    new Scope[] { Scope.DataRead, Scope.DataCreate, Scope.AccountWrite, Scope.BucketDelete });
                Response.Redirect(oauthUrl);
            }

            return;
        }
        // For a synchronous example refer to the 2legged example

        // Asynchronous example (recommended)
        internal static void _3leggedAsync(NewBearerDelegate cb)
        {
            try {
                if (!HttpListener.IsSupported)
                {
                    return;                      // HttpListener is not supported on this platform.
                }
                // Initialize our web listerner
                _httpListener = new HttpListener();
                _httpListener.Prefixes.Add(FORGE_CALLBACK.Replace("localhost", "+") + "/");
                _httpListener.Start();
                //IAsyncResult result =_httpListener.BeginGetContext (new AsyncCallback (_3leggedAsyncWaitForCode), _httpListener) ;
                IAsyncResult result = _httpListener.BeginGetContext(_3leggedAsyncWaitForCode, cb);

                // Generate a URL page that asks for permissions for the specified scopes, and call our default web browser.
                string oauthUrl = _threeLeggedApi.Authorize(FORGE_CLIENT_ID, oAuthConstants.CODE, FORGE_CALLBACK, _scope);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(oauthUrl));

                //result.AsyncWaitHandle.WaitOne () ;
                //_httpListener.Stop () ;
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }