Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-11603

OAuth authorize javascript error with System.Windows.Forms.WebBrowser

    XMLWordPrintable

Details

    Description

      If you open OAuth authorize url (example) within self-hosted WebBrowser control on windows (eg. .NET) you get javscript error:

      javascript error at https://d3oaxc4q5k2d6q.cloudfront.net/m/3d70c2b99510/dist/main.js
      

      Sample PowerShell code:

      $authorizeUri = "https://bitbucket.org/site/oauth2/authorize?client_id=hmepwfg9wqvXypWYAW&response_type=code"
      
      Add-Type -AssemblyName System.Windows.Forms
      $OnDocumentCompleted = {
        if($web.Url.AbsoluteUri -match "code=([^&]*)") {
      	$script:AuthCode = $Matches[1]
      	$form.Close()
        }
        elseif($web.Url.AbsoluteUri -match "error=") {
      	$form.Close()
        }
      }
      
      $web = New-Object System.Windows.Forms.WebBrowser -Property [~legacy-bitbucket-user]
      $web.Add_DocumentCompleted($OnDocumentCompleted)
      $form = New-Object System.Windows.Forms.Form -Property [~legacy-bitbucket-user]
      $form.Add_Shown({$form.Activate()})
      $form.Controls.Add($web)
      $web.Dock = "Fill"
      
      # Request Authorization Code
      $web.Navigate($authorizeUri)
      $null = $form.ShowDialog()
      
      

      Attachments

        1. bitbucket-jserror.PNG
          bitbucket-jserror.PNG
          8 kB
        2. sample-ui.ps1
          0.7 kB

        Activity

          People

            Unassigned Unassigned
            9a9170e002a0 matejskubic
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: