Community
BIM 360 API Forum
Welcome to Autodesk’s BIM 360 API Forums. Share your knowledge, ask questions, and explore popular BIM 360 API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C# webbrowser Authentication 3 Legged implicit cant get Forge accesskey

1 REPLY 1
Reply
Message 1 of 2
GrahamB8
451 Views, 1 Reply

C# webbrowser Authentication 3 Legged implicit cant get Forge accesskey

Hi all,

Im having an issue getting the Forge access key through a .net webbrowser for my first attempt at a 360docs Forge application. 

Everything works in Postman, the URL also works when pasted into IE11.

My webbrowser brings up the username and password forms successfully but on pressing 'Allow' in the Authorize application form I'm struggling to capture the access token, the button registers the click but the WebBrowserNavigatedEventArgs event isn't firing.

 

I would be grateful for any advice given

 

Here's my current code

public Form1()
        {
            InitializeComponent();
            webBrowser1.ScriptErrorsSuppressed = true;
            string clientID = Environment.GetEnvironmentVariable("B2VClientId", EnvironmentVariableTarget.User);
            string forgeRedirectUrl = Environment.GetEnvironmentVariable("B2VForgeRedirectUrl", EnvironmentVariableTarget.User);
            string forgeScope = Environment.GetEnvironmentVariable("B2VForgeScope", EnvironmentVariableTarget.User);
            webBrowser1.Url = new Uri("https://developer.api.autodesk.com/authentication/v1/authorize?" +
                                             "response_type=token" +
                                             "&client_id=" + clientID +
                                             "&redirect_uri=" + forgeRedirectUrl +
                                             "&scope=" + forgeScope);
        }
        private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            var url = e.Url.ToString();
            if (url.Contains("access_token"))
            {
                MessageBox.Show(url);
            }
        }
1 REPLY 1
Message 2 of 2
xiaodong_liang
in reply to: GrahamB8

Hi @GrahamB8,

 

I think the blog our colleague wrote has demoed how to work with 3legged token workflow with webbrowser. 

https://forge.autodesk.com/cloud_and_mobile/2016/10/3-legged-oauth-on-desktop-apps-c-winform.html

Could you check it helps your case?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report