token em vbnet incluido no header da requisição
Const client_id = "XXXX.apps.googleusercontent.com"
Const client_secret = "XXXXXXXXXXX"
Const refresh_token = "XXXXXXXXXX"
Const nome_aplicacao = "MinhaAplicacao"
Const user_id = "[email protected]"
Private Function CriaContactRequest(Optional scope As String = "https://www.google.com/m8/feeds https://www.google.com/m8/feeds/groups/default/full") As ContactsRequest
Try
Dim rs = New RequestSettings(nome_aplicacao) With { _
.OAuth2Parameters = New OAuth2Parameters() With { _
.AccessToken = refresh_token, _
.RefreshToken = refresh_token, _
.ClientId = client_id, _
.ClientSecret = client_secret, _
.RedirectUri = redirect_uri, _
.Scope = scope _
} _
}
Dim cr As New ContactsRequest(rs)
Return cr
Catch ex As Exception
Throw ex
End Try
End Function
3
2
Private Sub ConectaPlanilhaFuncional(scope As String)
Dim certificate As New X509Certificate2(Server.MapPath("/certificate/key.p12"), "notasecret", X509KeyStorageFlags.Exportable)
Dim credential = New ServiceAccountCredential(New ServiceAccountCredential.Initializer(service_email) With { _
.Scopes = New String() {scope}
}.FromCertificate(certificate))
Try
credential.RequestAccessTokenAsync(System.Threading.CancellationToken.None).Wait()
Catch ex As Exception
End Try
Dim requestFactory As New GDataRequestFactory(nome_aplicacao)
requestFactory.CustomHeaders.Add(String.Format("Authorization: Bearer {0}", credential.Token.AccessToken))
Dim myService As New SpreadsheetsService(nome_aplicacao)
myService.RequestFactory = requestFactory
Dim query As New SpreadsheetQuery()
Dim feed As SpreadsheetFeed = myService.Query(query)
For Each f As SpreadsheetEntry In feed.Entries
Dim texto As String = f.Title.Text
Next
End Sub
Thank you!
2
0
Are there any code examples left?
New code examples in category BASIC
-
BASIC 2022-03-27 17:45:10 JWT EM VBNET
-
BASIC 2022-03-20 07:40:02 get unique random number in vb.net
-
BASIC 2022-03-11 21:30:23 visual basic for loop
-
BASIC 2022-03-03 04:25:02 dos/cmd equivalent to "head"
-
BASIC 2022-02-26 20:20:04 mid visual basic function
-
BASIC 2022-02-23 02:15:02 vscode unindent
-
BASIC 2022-02-18 16:20:01 freecodecamp basic algorithm scripting return largest numbers in arrays
-
BASIC 2022-02-10 15:10:40 visual basic how to create a dynamic button
-
BASIC 2022-02-04 20:30:23 tmux basic commands