I'm having trouble with the following code while writing my Coinbase app. I'm able to obtain the access code, but I can't seem to get any further. I need to get the access token. I've pretty much followed the gmail tutorial but this just doesn't seem to work for my Coinbase app, or at least I haven't figured out how to make it work. So, what actually does the HttpUtils.postString do? When I manually input the commands in a web browser after I select "Authorize" I get a blank screen and the authorization code in the url (see attached photos). This is where the problem begins. I try to use that authorization in a post command using httputils and then parse the result. The trouble is I don't believe anything is coming back. Any suggestions?
B4X:
Sub GetAccessToken
Dim postString As String
'Msgbox("postString ","")
postString = "grant_type=" & AuthorizationCode & "&code=CODE&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client_id=" & clientId & "&client_secret=" & clientSecret
Msgbox("postString " & postString & "","")
HttpUtils.postString("GetAccessToken", "https://coinbase.com/oauth/token", postString)
ProgressDialogShow("Sending authentication request...")
Msgbox("Trying to Get Access Token ","")
End Sub
Sub Activity_Resume
If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub JobDone (Job As String)
ProgressDialogHide
Select Job
Case "GetAccessToken"
Dim url As String
url = HttpUtils.Tasks.Get(0)
Msgbox("URL is " & url & "" , "")
'Log(HttpUtils.GetString(url))
If HttpUtils.IsSuccess(url) Then
Dim Parser As JSONParser
Parser.Initialize(HttpUtils.GetString(url))
Dim m As Map
m = Parser.NextObject
AccessToken = m.Get("access_token")
Msgbox("AccessToken is " & AccessToken & "" , "")
'you may also want to get the refresh_token
RequestAddressesList
Else
ToastMessageShow("Error getting access TOKEN", True)
Button1.Enabled = True
End If
Case "AddressesList"
Dim url As String
url = HttpUtils.Tasks.Get(0)
If HttpUtils.IsSuccess(url) Then
ListView1.Clear
XmlParser.Parse(HttpUtils.GetInputStream(url), "xml")
Else
ToastMessageShow("Error getting addresses list", True)
End If
Button1.Enabled = True
End Select
HttpUtils.Complete = False
End Sub