VB.NET Help creating login function for custom launcher!

Discussion in 'Programming' started by TheRavenBlue, Apr 30, 2017.

  1. I'm currently creating my own Launcher in VB.NET and everything is basically done except some small things as custom JVM arguments.

    I'm currently stuck at creating some sort of login function I have read a bit here:
    http://wiki.vg/Authentication

    I have one idea that might work, and that is to have some sort of PHP script that fetches the accesstoken.
    I do not have much experience in VB.NET I did this as an challenge to learn more.

    This is how it looks at the moment:
    https://gyazo.com/af17968c14658ce4ea433bfeb993204a

    Do anyone have any idea on how I should make my login function and if someone would like to help out / bring new ideas that would be great!
     
  2. I managed to get it fixed if someone else needs login function for VB.net here you have it:

    Code (Text):
        Private ACCESS_TOKEN As String
        Public Function GetAccessToken() As String
            Return ACCESS_TOKEN
        End Function
        Public Sub ObtainAccessToken(username As String, password As String)
            Dim UUID As String = Guid.NewGuid.ToString()
            Dim httpWebRequest = DirectCast(WebRequest.Create("https://authserver.mojang.com/authenticate"), HttpWebRequest)
            httpWebRequest.ContentType = "application/json"
            httpWebRequest.Method = "POST"

            Using streamWriter = New StreamWriter(httpWebRequest.GetRequestStream())
                Dim json As String = (Convert.ToString((Convert.ToString("{""agent"":{""name"":""Minecraft"",""version"":1},""username"":""") & username) + """,""password"":""") & password) + """,""clientToken"":" & ControlChars.Quote & UUID & ControlChars.Quote & "}"

                streamWriter.Write(json)
                streamWriter.Flush()
                streamWriter.Close()

                Dim httpResponse = DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)
                Using streamReader = New StreamReader(httpResponse.GetResponseStream())
                    Dim result = streamReader.ReadToEnd()
                    ACCESS_TOKEN = result
                    MessageBox.Show(result)
                End Using
            End Using
        End Sub
     
  3. Hey so but what should i do with this? how do i start Minecraft with this information?
     
  4. You don’t. This isn’t even all the code for the launcher.
     
  5. Strahan

    Benefactor

    Why? If you want to dive into a .NET language, I'd be spending my efforts on C# not VB.
     
  6. I wholeheartedly agree with you but
    [​IMG]

    For whatever reason, I've been watching this thread since it was originally posted 2 years ago, and it's been a joy to read all the belated activity... but come on guys, this thread is ancient!
     
  7. Strahan

    Benefactor

    lol, I didn't even notice it was a necro.