I am new to Visual Basic and this forum, so I hope I am posting in the right forum.
I am writing an application which will run on the windows desktop and will make various use of internet connections.
My main problem at present is acquiring authorisation from the Google API.
This apparently has to be achieved via several steps in order to acquire access to a users information.
My code (below), requests authorisation and as I am not using a webbrowser the authorisation response has to be returned via localhost port.
(This is Google's preferred method apparently)
My request seems to be accepted as the server is not rejecting it, however I now need to understand how to listen out on the localhost port so that I may receive the authorisation request response.
redirect_uri=http://localhost/8080/
Could anyone please advise me on how this may be achieved?
Code follows:
vb.net Code:
Imports System.Net
Imports System.Text
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim request As WebRequest
' Request authorisation from Google API
request = DirectCast(WebRequest.Create("https://accounts.google.com/o/oauth2/auth?response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&redirect_uri=http://localhost/8080/&client_id=nnnnnnnnnnn.apps.googleusercontent.com"), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(request.GetResponse, HttpWebResponse)
Dim stream As New StreamReader(response.GetResponseStream)
Dim shorturl As String = stream.ReadToEnd
shorturl = stream.ReadToEnd
MessageBox.Show(shorturl)
End Sub
End Class
Regards
Quest2chill