Youtube Data API

  • VB.NET
  • .NET (FX) 4.5–4.8

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von TTX.exe.

    Youtube Data API

    Hi Leute :)

    ich schlage mich gerade mit Youtube rum und versuche in VB.Net Zugriff auf die Videos zu bekommen, anhand eines Beispiels sähe das so aus:

    VB.NET-Quellcode

    1. #Region "YouTube Credentials And YouTube Channel"
    2. Private Async Function GetGredentials() As Task
    3. Try
    4. Debug.WriteLine("Begin: GetCredentials")
    5. '
    6. ' ClientId and ClientSecret are found in your client_secret_*****.apps.googleusercontent.com.json file downloaded from
    7. ' the Google Developers Console ( https://console.developers.google.com).
    8. ' This sample shows the ClientID and ClientSecret in the source code.
    9. ' Other samples in the sample library show how to read the Client Secrets from the client_secret_*****.apps.googleusercontent.com.json file.
    10. '
    11. OAUth2Credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync( _
    12. New ClientSecrets With {.ClientId = "Your Client ID goes here ..............................................", _
    13. .ClientSecret = "Your Client Secret goes here."}, _
    14. {YouTubeService.Scope.Youtube}, "user", CancellationToken.None)
    15. Debug.WriteLine("End: GetCredentials")
    16. If OAUth2Credential IsNot Nothing Then
    17. If OAUth2Credential.Token IsNot Nothing Then
    18. Debug.WriteLine(String.Concat("Token Issued: ", OAUth2Credential.Token.Issued))
    19. End If
    20. End If
    21. Catch ex As Exception
    22. MsgBox(ex.Message, MsgBoxStyle.Critical, "Google Authorization")
    23. End
    24. End Try
    25. End Function
    26. Private Sub GetChannelDetail()
    27. Dim objYouTubeService As YouTubeService
    28. Debug.WriteLine("Begin: GetChannel")
    29. Try
    30. objYouTubeService = New YouTubeService(New BaseClientService.Initializer() With { _
    31. .HttpClientInitializer = OAUth2Credential, _
    32. .GZipEnabled = True, _
    33. .ApplicationName = Assembly.GetExecutingAssembly().GetName().Name})
    34. Catch ex As Exception
    35. MsgBox(ex.Message, MsgBoxStyle.Critical, "ValidateChannel - Initialize YouTubeService")
    36. End
    37. End Try
    38. Dim objChannels As ChannelListResponse = Nothing
    39. Try
    40. Dim objRequest As ChannelsResource.ListRequest = New ChannelsResource.ListRequest(objYouTubeService, "id,snippet")
    41. objRequest.Mine = True
    42. objRequest.Fields = "items"
    43. objChannels = objRequest.Execute
    44. Catch ex As Exception
    45. MsgBox(ex.Message, MsgBoxStyle.Critical, "GetChannel - Channel List Request")
    46. End
    47. End Try
    48. With objChannels.Items(0)
    49. 'txtChannel.Text = .Snippet.Title
    50. 'txtChannelDescription.Text = .Snippet.Description
    51. End With
    52. Debug.WriteLine("End: GetChannel")
    53. End Sub
    54. #End Region


    Allerdings wird hier folgendes angeprangert:

    'GoogleWebAuthorizationBroker' is not declared. It may be inaccessible due to its protection level. (BC30451)


    Mir ist jetzt nicht klar was sein Problem hier ist, laut dem Example funktioniert das so und GoogleWebAuthorizationBroker wird sonst nirgends besonders deklariert. Die entsprechenden Imports sind gesetzt, jemand eine Idee was genau das Problem ist?
    : NV Updater | Nvidia Driver Update Tool
    Moin,

    wo hast du das Example her? Sollte das exakt so existieren ist es Müll.

    Grüße
    "Life isn't about winning the race. Life is about finishing the race and how many people we can help finish the race." ~Marc Mero

    Nun bin ich also auch soweit: Keine VB-Fragen per PM! Es gibt hier ein Forum, verdammt!
    Puh ich hab keine Ahnung mehr wo das her ist...diese Youtube-Api macht mich wahnsinnig. Der Fehlerlag irgendwie an den DLLs, ich hab die nochmal alle weggeworfen und wieder neu geladen dann ging es.

    VB.NET-Quellcode

    1. Private Async Function GetGredentials() As Task
    2. Try
    3. Debug.WriteLine("Begin: GetCredentials")
    4. '
    5. ' ClientId and ClientSecret are found in your client_secret_*****.apps.googleusercontent.com.json file downloaded from
    6. ' the Google Developers Console ( https://console.developers.google.com).
    7. ' This sample shows the ClientID and ClientSecret in the source code.
    8. ' Other samples in the sample library show how to read the Client Secrets from the client_secret_*****.apps.googleusercontent.com.json file.
    9. OAUth2Credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(
    10. New ClientSecrets With {.ClientId = "dererer",
    11. .ClientSecret = "ererer"},
    12. {YouTubeService.Scope.Youtube}, "user", CancellationToken.None)
    13. Debug.WriteLine("End: GetCredentials")
    14. If OAUth2Credential IsNot Nothing Then
    15. If OAUth2Credential.Token IsNot Nothing Then
    16. Debug.WriteLine(String.Concat("Token Issued: ", OAUth2Credential.Token.Issued))
    17. End If
    18. End If
    19. Catch ex As Exception
    20. MsgBox(ex.Message, MsgBoxStyle.Critical, "Google Authorization")
    21. End
    22. End Try
    23. End Function


    Leider funzt das ganz und gar nicht, da er immer jammert:

    The redirect URI in the request, localhost:54799/authorize/, does not match the ones authorized for the OAuth client. Visit console.developers.google.com


    Obwohl diese da freigeben ist... :(

    Edit: Das Example war glaub das hier: codeproject.com/Tips/801604/Sa…ing-Google-APIs-for-NET-V
    : NV Updater | Nvidia Driver Update Tool

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „TTX.exe“ ()