Blog

  • Generate Battle.net OTP with PowerShell for 1Password

    Disclaimer: This article is provided as-is, without any warranties. Use the code at your own risk. I am not responsible for any issues or mistakes that may arise. If you choose to use or reference this code, please make sure to avoid logging out of your Battle.net account and test it in a separate browser to ensure everything runs smoothly.

    A while back, I stumbled upon a Python script that allowed me to add my Battle.net Authenticator OTP to my Authy account, which was super convenient at the time. However, as I started using 1Password more frequently, I decided to migrate all my OTPs there. Most sites were straightforward—just disable two-factor authentication set up in Authy, regenerate the QR code, and scan it into 1Password. But when it came to Battle.net, things got complicated. I went down quite the rabbit hole, and I’m sharing this guide to help you avoid the same hassle.

    The Problem

    I initially found a site that discussed the “old” method to transfer Battle.net OTPs, but Blizzard has deprecated that approach. They now use a bearer token method to access your account. While the page did link to what might be the original script and some troubleshooting advice, I found it a bit outdated.

    My Solution

    I started by setting up Python on my computer and attempted to use the code I found. While the last post on the GitHub article seemed to work, I prefer working in PowerShell, so I enlisted ChatGPT’s help to convert everything over. Here are the steps, with some credit to @BillyCurtis for his contributions.

    Prerequisites

    Before we dive in, ensure you’re logged into your Battle.net account and have an “Authenticator” added to your account.

    Step 1: Get Your Login Token

    1. Open a browser and enable “Developer mode” (F12 in most browsers).
    2. Log in to Battle.net and go to the “Application” section of the developer tools.Look for the “Cookies” section and find the entry for https://account.battle.net.Locate the cookie named “BA-tassadar”—this is your login token.
    3. Copy its value and keep it handy.

    Step 2: Generate Your Bearer Token

    1. Open PowerShell ISE and use the following script to generate your bearer token. Replace LOGIN_TOKEN with the token you copied in the previous step.
    # Generates your access token "Bear Token"
    
    # Define the headers
    $headers = @{
        "content-type" = "application/x-www-form-urlencoded; charset=utf-8"
    }
    
    # Define the data
    $body = "client_id=baedda12fe054e4abdfc3ad7bdea970a&grant_type=client_sso&scope=auth.authenticator&token=LOGIN_TOKEN"
    
    # Define the URL
    $url = "https://oauth.battle.net/oauth/sso"
    
    # Make the POST request
    $response = Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $body -ContentType "application/x-www-form-urlencoded"
    
    # Output the response
    $response

    Step 3: Generate Your Device Secret

    1. Create a new file in PowerShell ISE and use the script below to generate your device secret. Replace with the access_token from the previous step.
    2. You’ll also need your Authenticator “Restore Code” and “Serial” from the Battle.net website or phone app. In the Battle.net app, go to the “Authenticator” section, then click the gear icon, and select “Serial & Restore Codes”. Enter these details into the script below:
    # Generates the authenticator deviceSecret
    
    $headers = @{
        "Authorization" = "Bearer <BEARER_TOKEN>"
        "Accept"        = "application/json"
        "Content-Type"  = "application/json"
    }
    
    $body = @{
        serial      = "<SERIAL>"
        restoreCode = "<RESTORE_CODE>"
    } | ConvertTo-Json
    
    $url = "https://authenticator-rest-api.bnet-identity.blizzard.net/v1/authenticator/device"
    
    Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $body
    • If successful, this script will return your deviceSecret.

    Step 4: Convert Your Device Secret to OTPAUTH

    1. Copy the following code into a new PowerShell script. Replace <DEVICE_SECRET> with the deviceSecret you received from the previous step.
    # Function to convert a hex string to a byte array
    function Convert-HexStringToByteArray {
        param (
            [string]$hexString
        )
    
        $hexString = $hexString -replace ' ', ''  # Remove any spaces if present
        $byteArray = @()
    
        for ($i = 0; $i -lt $hexString.Length; $i += 2) {
            $byteArray += [Convert]::ToByte($hexString.Substring($i, 2), 16)
        }
    
        return $byteArray
    }
    
    # Base32 encoding function
    function Convert-ToBase32 {
        param (
            [byte[]]$bytes
        )
    
        $alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
        $output = ""
        $bitBuffer = 0
        $bitBufferLen = 0
    
        foreach ($byte in $bytes) {
            $bitBuffer = ($bitBuffer -shl 8) -bor $byte
            $bitBufferLen += 8
            while ($bitBufferLen -ge 5) {
                $output += $alphabet[($bitBuffer -shr ($bitBufferLen - 5)) -band 31]
                $bitBufferLen -= 5
            }
        }
    
        if ($bitBufferLen -gt 0) {
            $output += $alphabet[($bitBuffer -shl (5 - $bitBufferLen)) -band 31]
        }
    
        return $output
    }
    
    # Input: Hex string
    $hexString = "<DEVICE_SECRET>"
    
    # Convert the hex string to a byte array
    $byteArray = Convert-HexStringToByteArray -hexString $hexString
    
    # Encode the byte array to Base32
    $base32Encoded = Convert-ToBase32 -bytes $byteArray
    
    # Generate the OTPAUTH URL
    $otpAuth= "otpauth://totp/Battle.net?secret=$($base32Encoded)&digits=8"
    
    $otpAuth
    1. Run the script, and if all goes well, you should get a URL in the format “otpauth://totp/Battle.net?secret=…&digits=8”.

    Step 5: Add to 1Password

    1. With the generated URL, you can now add a new OTP entry in 1Password.
    2. Paste the “otpAuth” into the “appropriate “one-time password code” field when creating a one-time password for your Battle.net account in 1Password.

    Conclusion

    It’s a bit complicated, but not impossible! With patience and the steps outlined above, you should be able to transfer your Battle.net OTP to 1Password successfully. Good luck!

  • Discovering the .vsconfig File in Unreal Engine 5.4 Projects

    Did you know that when you create an Unreal Engine 5.4 project (and possibly earlier versions), it automatically generates a .vsconfig file in your project folder?

    What is a .vsconfig File?

    You might be wondering, “What does a .vsconfig file do?” Well, at first glance, it might not seem like much. However, if you take a closer look, you’ll find several lines specifying Microsoft Visual Studio components. Essentially, this file lists the necessary Visual Studio components required for building and compiling your Unreal Engine game code.

    So, What Can You Do with This File?

    Here’s the neat part: instead of manually configuring Visual Studio by checking all the required boxes, you can simply import this file into the Visual Studio Installer. This will automatically configure all the settings for you, saving time and ensuring you have everything you need to start coding.

    How to Import the .vsconfig File:

    1. Launch the Visual Studio Installer.
    2. Click the “More” button, then select “Import configuration.”
    3. Navigate to your Unreal Engine project folder and select the .vsconfig file.
    4. Click “Review details,” then hit “Install.”

    And that’s it! Magic, right? Well, almost…

    Troubleshooting a Common Error

    In my case, I encountered an error: “The following packages could not be installed… Microsoft.VisualStudio.Component.Windows10SDK.22621: No matching package found.”

    After a quick check on the Visual Studio Community components page, I noticed that there was no package available for Windows 10 SDK 22621. Instead, I found one for the Windows 11 SDK, labeled Microsoft.VisualStudio.Component.Windows11SDK.22621.

    To fix this, I simply edited the .vsconfig file by removing the Windows 10 SDK 22621 entry and adding these two lines:

    "Microsoft.VisualStudio.Component.Windows10SDK.18362",
    "Microsoft.VisualStudio.Component.Windows11SDK.22621",

    I saved the file, re-ran the installer, and voilà—a happy .vsconfig file and a properly configured Visual Studio.

    I hope this helps you, and happy coding!

  • Horizon View – Fault type is VC_FAULT_FATAL

    Issue:

    Trying to push a new image to a desktop pool, and got a provisioning error:

    Fault type is VC_FAULT_FATAL – A general system error occurred: Connection refused

    After searching for a fix, I came across this article from VMware.

    Solution:

    Restarting vCenter that Horizon View is referencing seems to address the issue.

    https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2118319

  • Invalid configuration for device ‘1’ or ‘0’

    I had a tons of errors in vCenter in the recent tasks list when recomposing a pool:

    Invalid configuration for device ‘0’
    Invalid configuration for device ‘1’

    After calls to Vmware support, which they couldn’t pinpoint the error, I sat and watched my VMs being created by composer.

    My templates kept showing AppStack vdmks being added during the recompose process, and the pool would fail to publish.

    I checked the AppVolumes assignments, and I guess name filtering wasn’t applied correct and was assigning the AppStacks to all the VMs in the OU.  Reassigning the AppStack with name filtering turned on resolved the issue.

  • Unreal UWP

    I was having issues compiling the Windows Universal Platform version of the Unreal Game Engine.
    https://forums.unrealengine.com/showthread.php?118375-Unreal-Engine-4-is-available-for-Win10-UWP-app-dev-now

    I kept getting ‘/FU’ requires an argument, and would fail compiling.

    After lots of troubleshooting, it turns out that I just need to downgrade my Windows 10 SDK to version 10.0.14393.795.

    Here is a list of all the current versions of the SDK.
    https://developer.microsoft.com/en-us/windows/downloads/sdk-archive

  • Visual Studio 2015 update 2 install

    I recently ran into some issues compiling an older version of the Unreal 4 game engine, and needed to downgrade my Visual Studio 2015 update 3 to update 2.

    During a fresh install, the Visual Studio installer automatically goes out, and downloads the latest updates which was update 3.

    After so scouring the web, I found a Microsoft site that shows how to install previous versions via command line, but here is the grid, just in case the site goes away.

    Visual Studio 2015 editionWhat to runCommand-line to useWhat setup does
    Visual Studio Enterprise (the latest public release)Visual Studio Enterprise with Updates (available fromMy.VisualStudio.com)vs_enterprise.exe Note: The default behavior of this installation offers the most recent optional features and therefore, it does not require any command-line parameters.Visual Studio setup will use the most recent feed.xml and install the most recent files
    Visual Studio Enterprise Update 3 (the original Update 3 without any further Update 3-era updates)Visual Studio Enterprise RTM (available from the MSDN Subscriptions download page)vs_enterprise.exe /OverrideFeedURI http://download.microsoft.com/download/6/B/B/6BBD3561-D764-4F39-AB8E-05356A122545/20160628.2/enu/feed.xmlVisual Studio setup will use the feed.xml that was available when Update 3 released
    Visual Studio Enterprise Update 2 (the original Update 2, but with updates that pre-date Update 3)Visual Studio Enterprise RTM (available from the MSDN Subscriptions download page)vs_enterprise.exe /OverrideFeedURI http://download.microsoft.com/download/6/B/B/6BBD3561-D764-4F39-AB8E-05356A122545/20160620.2/enu/feed.xmlVisual Studio setup will use the feed.xml that was current before Update 3 released
    Visual Studio Enterprise (the original Update 2 without any further Update 2-era updates)Visual Studio Enterprise RTM (available from the MSDN Subscriptions download page)vs_enterprise.exe /OverrideFeedURI http://download.microsoft.com/download/0/6/B/06BB0C5C-C767-4250-91DA-AB463377597E/20160405.3/enu/feed.xmlVisual Studio setup will use the feed.xml that was available when Update 2 released
    Visual Studio Enterprise Update 1 (the original Update 1, but with updates that pre-date Update 2)Visual Studio Enterprise RTM (available from the MSDN Subscriptions download page)vs_enterprise.exe /OverrideFeedURI http://download.microsoft.com/download/3/2/A/32A1974F-D236-43C1-8981-97DDCBAEF14A/20160225.3/enu/feed.xmlVisual Studio setup will use the feed.xml that was current before Update 2 released
    Visual Studio Enterprise Update 1 (the original Update 1 without any further Update 1-era updates)Visual Studio Enterprise RTM (available from the MSDN Subscriptions download page)vs_enterprise.exe /OverrideFeedURI https://download.microsoft.com/download/3/2/A/32A1974F-D236-43C1-8981-97DDCBAEF14A/20151201.1/enu/feed.xmlVisual Studio setup will use the feed.xml that was available when Update 1 released
    Visual Studio Enterprise (the original RTM, but with updates that pre-date Update 1)Visual Studio Enterprise RTM (available from theMSDN Subscriptions download page)vs_enterprise.exe /OverrideFeedURI https://download.microsoft.com/download/3/6/1/36188D5F-479F-4A46-BF55-6AE5928D1EBB/20151102.3/enu/feed.xmlVisual Studio setup will use the feed.xml that was current before Update 1 released
    Visual Studio Enterprise (the original RTM with no updates)Visual Studio Enterprise RTM (available from the MSDN Subscriptions download page)vs_enterprise.exe /OverrideFeedURI https://download.microsoft.com/download/5/7/B/57BF5016-E4F0-4EB5-BE27-2BFA87E7723F/20150713.1/enu/feed.xmlVisual Studio setup will use the feed.xml that was available when RTM released

    Source: https://msdn.microsoft.com/en-us/library/mt653628.aspx

  • Error on login either ‘-r’ or ‘-s’ must be specified

    Issue:

    We recently upgraded to VMWare App Volumes 2.11 and had an issue on login to a Windows 7 VDI system where users were getting the following message:

    “Error on login either ‘-r’ or ‘-s’ must be specified”

    After submitting a ticket to VMware, the issue was with UEM 9.0 and the App Volumes 2.11 template file.

    Resolution:

    There is a switched built into the AppStacks script allvolattached_shellstart.bat. The call in the script is to use FlexEngine.exe -ra which is not used in UEM 9.0. You will need to adjust that to read FlexEngine.exe -UEMRefreshShortcuts for UEM 9.0.

    For the existing AppStacks you can update the AppStack and make the changes during provisioning mode.

    In Windows change to show hidden folders and hidden system folders. Browse to C:\SnapVolumesTemp\MountedDevices\ Open allvolattached_shellstart.bat with notepad and look for FlexEngine.exe -ra Change from -ra to -UEMRefreshShortcuts

    Hope this helps you 🙂

  • SQLite Integration Unreal 4.12.5 easy?

    I got excited to see code in the latest release of Unreal 4.12.5 to support SQLite intetration which I plan to use for dedicated servers for storing inventory and player data.

    I followed lots of post down interesting rabbit holes. For your personal reading enjoyment, here they are.

    This was my first stop, when googling the errors I was getting and it did get me close but I ended up looking further… https://answers.unrealengine.com/questions/184626/sqlitesupport-module-currently-broken.html

    This find also helped a bit, but quickly realized that is probably is not what I need to be doing… search continues.https://www.reddit.com/r/unrealengine/comments/2xk2jq/problem_with_using_sqlitesupport_module/

    Good approach, and I thought I was on the right track, but did it does miss the exact step by step… so it didn’t end of working http://www.antonsetiawan.com/archives/2016/05/using-sqlite-as-datastore-in-unreal/

    In the end, I did find a solution. I made my own… Will it work in production? Too soon to tell, but… the code does compile and I will post the solution to the correct steps to at least get your code to compile. I might need to help Unreal with the changes, or maybe I am such a newbie I didn’t their instructions. Here, you decide 😉

    *SQLite database support requires the ‘amalgamated’ source code for sqlite, obtainable at http://www.sqlite.org/download.html. It also requires you to compile the engine from Github source code rather than using the precompiled binary builds from the Unreal Launcher.

    Download and extract the Unreal source as per the instructions on Github, then extract the contents (.cpp, .h) from the sqlite amalgamated zip into Engine/Source/ThirdParty/sqlite/sqlite and build it using VisualStudio.

    If you are already building the engine from source it is necessary to rebuild it once you’ve added the SQLite files.*

  • Hello world!

    Welcome to my IT mind dump, also known as my blog. This site is my repository for all the technical snippets and solutions I’ve gathered, helping me avoid repeating the same problem twice. It also serves as a record of the projects I’ve started (as hobbies) and completed. Hopefully, you’ll find something here that’s helpful as well.