Hi. I have created a VB.net youtube video uploader app using Google API, which works fine. However, if I want use a proxy to upload the video, I get an error: "Invalid credentials".

The proxy I am using is a public one and doesn't require any authentication, so I don't see what the problem could be.

My code:

Imports Google.GData.Extensions.Location
Imports Google.GData.Client
Imports Google.GData.YouTube
Imports Google.YouTube
Imports Google.GData.Extensions.MediaRss
Imports System.IO
Imports System.Text
Imports System.Net

Public Class vidUpload

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim newVideo As New Video()
    Dim err As Boolean = False
    Dim developerKey = "AI39si5m1puWrHCIEdKQ21J8CqpmiRfLZwQ77w8WtZYMcrR7tAnuJW-ysF0mkVnp5R_ETKnifuio6tAfTQo_PMXkrrp7u3v73A"
    Dim username = txtEmail.Text
    Dim password = txtPass.Text
    Dim settings As YouTubeRequestSettings = New YouTubeRequestSettings("Youtube uploader", developerKey, username, password)
    Dim request As YouTubeRequest = New YouTubeRequest(settings)
    Dim myProxy As New System.Net.WebProxy("", 8080) 'the proxy settings
    newVideo.Title = txtTitle.Text
    newVideo.Tags.Add(New MediaCategory(cmbCat.Text, YouTubeNameTable.CategorySchema))
    newVideo.Keywords = txtKwrd.Text
    newVideo.Description = txtDscr.Text
    newVideo.YouTubeEntry.[Private] = False
    myProxy.Credentials = New System.Net.NetworkCredential("", "") 'I think these should be empty strings
    myProxy.BypassProxyOnLocal = False

    newVideo.Tags.Add(New MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema))

    newVideo.YouTubeEntry.Location = New GeoRssWhere(37, -122)
    request.Proxy = myProxy
    ' alternatively, you could just specify a descriptive string
    ' newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA");

        newVideo.YouTubeEntry.MediaSource = New MediaFileSource(txtFile.Text, "video/quicktime")
        Dim createdVideo As Video = request.Upload(newVideo)
    Catch ex As Exception
        err = True
        MsgBox(ex.Message, MsgBoxStyle.Exclamation)
    End Try

    If newVideo.IsDraft = False And err = False Then
        MsgBox("Completed", MsgBoxStyle.Information, "Success!")
    End If

End Sub

Any suggestions appreciated!

Have you tried it without this line myProxy.Credentials
= New
("", "") ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.