ASP.NET VB

253 views
Skip to first unread message

Chase Spring

unread,
Apr 28, 2014, 10:48:57 AM4/28/14
to google-ca...@googlegroups.com
 I am trying to get the authentication to work.  My stream cannot be opened. Is there a way I can just hard code the credentials instead of reading them in from a JSON file? If so, what would the code look like? Thanks


 Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim scopes As IList(Of String) = New List(Of String)()
        '' Calendar service.
        Dim service As CalendarService
        ' Add the calendar specific scope to the scopes list.
        scopes.Add(CalendarService.Scope.Calendar)
        ' Display the header and initialize the sample.
        Dim credential As UserCredential
        Using stream As New FileStream((Server.MapPath("client_secret.json")), FileMode.Open, FileAccess.Read)


            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets, scopes, "user", CancellationToken.None,
                    New FileDataStore("Calendar.VB.Sample")).Result


        End Using
        ' Create the calendar service using an initializer instance
        Dim initializer As New BaseClientService.Initializer()
        initializer.HttpClientInitializer = credential
        initializer.ApplicationName = "VB.NET Calendar Sample"
        service = New CalendarService(initializer)
        ' Fetch the list of calendar list
        Dim list As IList(Of CalendarListEntry) = service.CalendarList.List().Execute().Items()
        ' Display all calendars
        DisplayList(list)
        For Each calendar As Data.CalendarListEntry In list
            ' Display calendar's events
            'DisplayFirstCalendarEvents(calendar)
        Next

    End Sub

Patrick Bibro

unread,
Aug 8, 2014, 6:24:15 PM8/8/14
to google-ca...@googlegroups.com
         credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    New ClientSecrets With {.ClientId = "", .ClientSecret = ""}, scopes, "user", CancellationToken.None,
                    New FileDataStore("Calendar.VB.Sample")).Result
Reply all
Reply to author
Forward
0 new messages