Question

This is with reference to using Google Contacts Data API. It requires that the application gets authentication view a WebBrowser/WebView (in the case of android). Therefore the RequestTokenUrl is passed to the webview which will show a Google Sign-in page and then ask the user if it allows the application to access their account. Once authorized, there needs to be some kind of callback to the activity. The activity will then use the WebViews cookie (which should contain the AccessToken) with an HTTP client to request data from Google Data API. This could be anything, in our case it is the Google Contacts. Any ideas on how this can be done?

EDIT: Found another way around the problem by using OAuth 2.0. This still required getting the AuthorizationCode from the WebView but that is accessed through the pagetitle instead of a cookie. The selected answer still addresses the original question correctly.

Was it helpful?

Solution

The following code which uses the reflection library will print a line with the cookies:

 Sub WebView1_PageFinished (Url As String)
    Dim r As Reflector
    r.Target = r.RunStaticMethod("android.webkit.CookieManager", "getInstance", Null, Null)
    Log(r.RunMethod2("getCookie", Url, "java.lang.String"))
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top