Android Question Trouble with Oauth and Coinbase

young61

Member
Licensed User
Longtime User
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
 

Attachments

  • AfterAuthorize.PNG
    AfterAuthorize.PNG
    15 KB · Views: 219
  • Authorize.PNG
    Authorize.PNG
    44.1 KB · Views: 245
  • SignIn.PNG
    SignIn.PNG
    32.2 KB · Views: 242

Erel

B4X founder
Staff member
Licensed User
Longtime User
I recommend you to switch to HttpUtils2 instead of HttpUtils.

PostString sends a POST request. You should check the documentation of this service and see whether you need a POST request or a GET request.

The Gmail example uses WebView to handle the authentication. Google returns the token in the page title. In your case you should handle the PageFinished event and get the token from the URL.
 
Upvote 0

young61

Member
Licensed User
Longtime User
I've progressed a little further. I am now able to get the authorization code and the access token (see updated code below). It took me a little while to get the"postString" command correct. Working in the browser url helped me figure that issue out. Now I don't know how to parse the information. I'm making the right call but I just don't know exactly how to handle what I'm getting back. My data is not being returned in the url, but on a web page based on my testing utilizing the correct post code in the url. Please see the pic of the data I'm receiving via the browser. So what do I need to use to parse this data?

B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        HttpUtils.CallbackActivity = "Main"
        HttpUtils.CallbackJobDoneSub = "JobDone"
        XmlParser.Initialize
    End If
    Activity.LoadLayout("Main")
    ListView1.Height = 100%y - ListView1.Top
End Sub

Sub Button1_Click
    If AuthorizationCode = "" Then
        'show a WebView that will ask the user to give us access
        Dim scope As String
        scope = "addresses"
        Dim wv As WebView
        wv.Initialize("wv")
        Activity.AddView(wv, 0, 0, 100%x, 100%y)
        wv.LoadUrl("https://coinbase.com/oauth/authorize?response_type=code&client_id=" _
            & clientId & "&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=" & scope)
        Button1.Enabled = False
    Else If AccessToken = "" Then
        GetAccessToken  
    Else
        RequestAddressesList
    End If
End Sub
'My idea of some code
Sub TwoFactorCheck
    Dim wv1 As WebView
    wv1.Initialize("wv")
    wv1.LoadUrl(AuthOrDeny)
    'Msgbox("AuthOrDeny " & AuthOrDeny & " is ready.", "")
End Sub

Sub wv_PageFinished (Url As String)
    'Msgbox("Page " & Url & " is ready.", "")
  
    If Url.StartsWith("https://coinbase.com/oauth/authorize?response") Then 'approval
        'Msgbox("Page " & Url & " is ready.", "")
        AuthOrDeny = Url    'I added this
        TwoFactorCheck
    End If
            'Msgbox("Now " & Url & " is this.", "")
            If Url.StartsWith("https://coinbase.com/oauth/authorize/") Then
            Dim wv As WebView
            wv = Sender
            Dim w As WebViewXtender
            Dim result As String
            result = w.getTitle(wv)
            Msgbox("Page Title is " & result & " huh.", "")
            wv.RemoveView 'remove the WebView
                'If result.StartsWith("Coinbase - Your Hosted Bitcoin Wallet") Then '"Coinbase - Your Hosted Bitcoin Wallet"
                AuthorizationCode = result      'result.SubString("Coinbase - Your Hosted Bitcoin Wallet".Length) '"Coinbase - Your Hosted Bitcoin Wallet"
                Msgbox("AuthCode= " & AuthorizationCode & "" ,"")
                Msgbox("About to Get Access Token ","")
                GetAccessToken
            '    Else
                Button1.Enabled = True
                Log("Error: " & result)
                ToastMessageShow(result, True)
            '    End If
        End If
    'End If
End Sub

Sub GetAccessToken
    Dim postString As String
    'Msgbox("postString ","")
    postString = "grant_type=authorization_code&code=" & AuthorizationCode & "&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)
            Msgbox("Address List Url is " & url & "" , "")
            If HttpUtils.IsSuccess(url) Then
                Msgbox("Got Here"  , "")
                ListView1.Clear
                XmlParser.Parse(HttpUtils.GetInputStream(url), "xml")
                Msgbox("Got Here Also"  , "")
            Else
                ToastMessageShow("Error getting addresses list", True)
            End If
            Button1.Enabled = True
    End Select
    HttpUtils.Complete = False
End Sub

Sub RequestAddressesList
    ProgressDialogShow("Sending addresses list request...")
    HttpUtils.Download("AddressesList", AddressesListLink & "?access_token=" & AccessToken & "&v=3.0&max-results=100")
End Sub
Sub XML_StartElement (Uri As String, Name As String, Attributes As Attributes)
  
End Sub
Sub XML_EndElement (Uri As String, Name As String, Text As StringBuilder)
    If Name = "fullName" Then
        ListView1.AddSingleLine(Text.ToString)
    End If
End Sub
 

Attachments

  • CB data.png
    CB data.png
    105.4 KB · Views: 251
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What does the

B4X:
Case "GetAccessToken"
  Dim url As String
  url = HttpUtils.Tasks.Get(0)
  Msgbox("URL is " & url & "" , "")

Msgbox show you?

The url like in your screen from your browser?

If so then you must split (parse) the url to get its subparts: access_token, v, max-results

First search the questionmark in url and put everything behind in a stringvariable.

Then you split the created string at &
- You get more parts...
Iterate through all parts and for each one you so a split again
- Split part at =
- You get two values. First is the name specified in url and one of these should be the "access_token". The second of splitted part is the value. In case that the first part is access_token then the second part is the access token. max-results is 100 and v is 3.0
 
Upvote 0

young61

Member
Licensed User
Longtime User
I'm getting the access token. The code is working for that. The problem now lies in getting the addresses. I'm not exactly sure what I need to do. The pic I included in my post shows what is being returned and it is being returned as json on a web page. That's what I need to parse. I just need a little guidance in getting started or what is the best approach.


What does the

B4X:
Case "GetAccessToken"
  Dim url As String
  url = HttpUtils.Tasks.Get(0)
  Msgbox("URL is " & url & "" , "")

Msgbox show you?

The url like in your screen from your browser?

If so then you must split (parse) the url to get its subparts: access_token, v, max-results

First search the questionmark in url and put everything behind in a stringvariable.

Then you split the created string at &
- You get more parts...
Iterate through all parts and for each one you so a split again
- Split part at =
- You get two values. First is the name specified in url and one of these should be the "access_token". The second of splitted part is the value. In case that the first part is access_token then the second part is the access token. max-results is 100 and v is 3.0
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I'm getting the access token. The code is working for that. The problem now lies in getting the addresses. I'm not exactly sure what I need to do. The pic I included in my post shows what is being returned and it is being returned as json on a web page. That's what I need to parse. I just need a little guidance in getting started or what is the best approach.

You mean your screen in CB data.png, right?

You have to parse the JSON-Array with jsonparser.

Can you copy the complete JSON-String here in a quote? I´ll help and give you an short description...
 
Upvote 0

young61

Member
Licensed User
Longtime User
{"addresses":[{"address":{"address":"12Bx6EFmxTXMKhZE9XgqU5kva2ie73c73P","callback_url":null,"label":null,"created_at":"2014-01-31T14:25:30-06:00"}},{"address":{"address":"1A6X2o9PUsUfiqCdk3mgkg5uqwLFhvY35p","callback_url":null,"label":null,"created_at":"2014-01-26T13:48:19-06:00"}},{"address":{"address":"1JTzSi5VrdgTczpuvzm7SSMiPatGyiy3nq","callback_url":null,"label":null,"created_at":"2014-01-24T20:30:30-06:00"}},{"address":{"address":"12GXzgLkrBLSVeYRQkCZFX2jgbSCNRCDXc","callback_url":null,"label":null,"created_at":"2014-01-15T16:27:34-06:00"}},{"address":{"address":"1N5mEKWKHjEUP1c37eSyoSW1Q6SDCWrr5N","callback_url":null,"label":null,"created_at":"2014-01-09T22:08:59-06:00"}},{"address":{"address":"1AQZZMkwPoPa4evAK8ubxkvXhf3XXJVXxV","callback_url":null,"label":null,"created_at":"2014-01-09T18:50:43-06:00"}},{"address":{"address":"14Lc6g7JweqEqSgzvUYzw4mA8LCMGF24MH","callback_url":null,"label":null,"created_at":"2013-12-30T12:27:27-06:00"}},{"address":{"address":"1PyVQSCyMycsbvWzdkVEhA1fTdJCUtLRnk","callback_url":null,"label":null,"created_at":"2013-12-27T19:37:10-06:00"}},{"address":{"address":"18aVYWf1kbiyNtBVyEAvDt5aaukpQ3cXhS","callback_url":null,"label":null,"created_at":"2013-12-24T00:49:21-06:00"}},{"address":{"address":"18ZuWiYLD3nN33VDp3okPKhrw3p8PjYhCq","callback_url":null,"label":null,"created_at":"2013-12-23T20:32:10-06:00"}},{"address":{"address":"1JsQRaWENhMoGK4bRo5a54ajpeet2yGhf1","callback_url":null,"label":null,"created_at":"2013-12-13T15:09:58-06:00"}},{"address":{"address":"1MWobJKiWNed92ZvgGU9Sv2c9WSgDZfVFG","callback_url":null,"label":null,"created_at":"2013-12-12T21:37:24-06:00"}},{"address":{"address":"1ETtv1brkBoVtp8obfS5Wp7YxEa9KhjRP9","callback_url":"","label":"Affiliate address","created_at":"2013-12-12T19:54:28-06:00"}},{"address":{"address":"1PHuW3YFSnUhwrAfBaYVZnmVVQPxaWPFGM","callback_url":null,"label":null,"created_at":"2013-12-11T17:26:59-06:00"}},{"address":{"address":"12JJq8yTrMBynpXG8TZRXxexW9aKamZHvk","callback_url":null,"label":null,"created_at":"2013-12-06T21:15:54-06:00"}},{"address":{"address":"1Ge34Mt9t9M9zMfJeBfnEP22vA3mBS8EZ8","callback_url":null,"label":null,"created_at":"2013-11-21T13:55:03-06:00"}},{"address":{"address":"1LtrzW1KzkzB7tEJS1Kn9Rw7AkPW37Evhk","callback_url":null,"label":null,"created_at":"2013-11-21T13:40:14-06:00"}},{"address":{"address":"1A8WCagmAkns4tYpUG64XzasG87NUg6BmS","callback_url":null,"label":null,"created_at":"2013-11-20T21:42:22-06:00"}},{"address":{"address":"18pxJTW9ja1EJCwUbG28by92bPV3eU1HRd","callback_url":null,"label":null,"created_at":"2013-11-20T14:46:35-06:00"}},{"address":{"address":"1CrFe7dju8DGfoY7oFWy2iQhvWMRtCYjDt","callback_url":null,"label":null,"created_at":"2013-11-20T14:02:25-06:00"}},{"address":{"address":"1MxbFw2WMZ6xN1oAbBscaE5QpaZ7DcDWLq","callback_url":null,"label":null,"created_at":"2013-11-20T14:01:13-06:00"}},{"address":{"address":"1Lz2DszYLSyMEYFiqmePrxAzcPaw5RKAXv","callback_url":"","label":"Chet - Strongcoin","created_at":"2013-11-19T09:35:39-06:00"}},{"address":{"address":"1DV32CXbhx3rKWQ4Y7DzwCPZ8LYseVqBM6","callback_url":null,"label":null,"created_at":"2013-11-19T09:32:15-06:00"}},{"address":{"address":"136tYmoMSFM7tieRH2sCTxRa5WQ2kZRo4N","callback_url":null,"label":null,"created_at":"2013-11-15T21:56:12-06:00"}},{"address":{"address":"17KHfmTVCPz65V5RbAckuuSUDZWZAVM8kW","callback_url":null,"label":null,"created_at":"2013-10-30T21:40:02-05:00"}}],"total_count":32,"num_pages":2,"current_page":1}

You mean your screen in CB data.png, right?

You have to parse the JSON-Array with jsonparser.

Can you copy the complete JSON-String here in a quote? I´ll help and give you an short description...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Please have a look at this example

The json you posted i have uploaded to a webserver. From this app i do a normal download. You can do any call you need in your working app...

The fact is that you have to parse the content (the returned answer) of website you have called...

More details (and code :D) you find in example ;)

It should show you the principle of handling json. Play with it :D
 

Attachments

  • young61.zip
    9.5 KB · Views: 230
Last edited:
Upvote 0

young61

Member
Licensed User
Longtime User
Many thanks! I'll give it a try this evening.

Please have a look at this example

The json you posted i have uploaded to a webserver. From this app i do a normal download. You can do any call you need in your working app...

The fact is that you have to parse the content (the returned answer) of website you have called...

More details (and code :D) you find in example ;)

It should show you the principle of handling json. Play with it :D
 
Upvote 0

young61

Member
Licensed User
Longtime User
I certainly appreciate your help, but let me ask you one more question. Utilizing the method in this example, how would read and parse the url? I'd like to replace the following code utilizing the HttpUtils2Service and HttpJob

B4X:
Sub GetAccessToken
    Dim postString As String
    'Msgbox("postString ","")
    postString = "grant_type=authorization_code&code=" & AuthorizationCode & "&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")



Please have a look at this example

The json you posted i have uploaded to a webserver. From this app i do a normal download. You can do any call you need in your working app...

The fact is that you have to parse the content (the returned answer) of website you have called...

More details (and code :D) you find in example ;)

It should show you the principle of handling json. Play with it :D
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I dont understand was exactly the question is. Can you explain more detailed what your goal is or what you want to know? Maybe it would help me if you find simpler instructions/question cause i did not understand what you want to do. My english sucks sometimes (I´m german) ;)
 
Last edited:
Upvote 0

young61

Member
Licensed User
Longtime User
Sure. I use Oauth and the Coinbase api to be granted access to my account. I have a client id and client secret code. I use those to obtain my authorization code. Once I have the authorization code, I then need to use a post command to obtain the access token. The post command returns a url that has the access token within it. I need to parse the url to get the access token. The code that I previously posted does that, but I was using Httputils and HttpUtilsService to accomplish the task. Supposedly it would be easier to do it with Httputils2 and HttpJob, which is what you used in your example. Your example parsed a webpage, not the url. I need to grab the url and parse that. After I have the access token, I need to use it in a get command to call the web page that has the json information. Once I have that I can use your example and parse the page. I pasted my full code below. It works getting the access token, but I don't think its optimum. It doesn't work getting the addresses.

B4X:
Sub Process_Globals
    Dim clientId As String : clientId = "xxxxxxxxxxxxxxxxxxxxxxx"
    Dim clientSecret As String : clientSecret = "yyyyyyyyyyyyyyyyyy"
    Dim AuthorizationCode, AccessToken As String
    Dim AddressesListLink As String : AddressesListLink = "https://coinbase.com/api/v1/addresses"
    Dim XmlParser As SaxParser
    Dim AuthOrDeny As String
    Dim gurl As String
  
End Sub

Sub Globals
    Dim Button1 As Button
    Dim ListView1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        HttpUtils.CallbackActivity = "Main"
        HttpUtils.CallbackJobDoneSub = "JobDone"
        XmlParser.Initialize
    End If
    Activity.LoadLayout("Main")
    ListView1.Height = 100%y - ListView1.Top
End Sub

Sub Button1_Click
    If AuthorizationCode = "" Then
        'show a WebView that will ask the user to give us access
        Dim scope As String
        scope = "addresses"
        Dim wv As WebView
        wv.Initialize("wv")
        Activity.AddView(wv, 0, 0, 100%x, 100%y)
        wv.LoadUrl("https://coinbase.com/oauth/authorize?response_type=code&client_id=" _
            & clientId & "&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=" & scope)
        Button1.Enabled = False
    Else If AccessToken = "" Then
        GetAccessToken  
    Else
        RequestAddressesList
    End If
End Sub
'My idea of some code
Sub TwoFactorCheck
    Dim wv1 As WebView
    wv1.Initialize("wv")
    wv1.LoadUrl(AuthOrDeny)
    'Msgbox("AuthOrDeny " & AuthOrDeny & " is ready.", "")
End Sub

Sub wv_PageFinished (Url As String)
    'Msgbox("Page " & Url & " is ready.", "")
  
    If Url.StartsWith("https://coinbase.com/oauth/authorize?response") Then 'approval
        'Msgbox("Page " & Url & " is ready.", "")
        AuthOrDeny = Url    'I added this
        TwoFactorCheck
    End If
            'Msgbox("Now " & Url & " is this.", "")
            If Url.StartsWith("https://coinbase.com/oauth/authorize/") Then
            Dim wv As WebView
            wv = Sender
            Dim w As WebViewXtender
            Dim result As String
            result = w.getTitle(wv)
            Msgbox("Page Title is " & result & " huh.", "")
            wv.RemoveView 'remove the WebView
                AuthorizationCode = result      
                Msgbox("AuthCode= " & AuthorizationCode & "" ,"")
                Msgbox("About to Get Access Token ","")
                GetAccessToken
            '    Else
                Button1.Enabled = True
                Log("Error: " & result)
                ToastMessageShow(result, True)
            '    End If
        End If
    'End If
End Sub

Sub GetAccessToken
    Dim postString As String
    'Msgbox("postString ","")
    postString = "grant_type=authorization_code&code=" & AuthorizationCode & "&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"  'This is the part that's not working
            Dim url As String
            url = HttpUtils.Tasks.Get(0)
            Msgbox("Address List Url is " & url & "" , "")
            If HttpUtils.IsSuccess(url) Then
            Msgbox("Got Here"  , "")
                ListView1.Clear
                XmlParser.Parse(HttpUtils.GetInputStream(url), "xml")
                m = parser.NextObject
                Msgbox("Got Here Also"  , "")
      
            Else
                ToastMessageShow("Error getting addresses list", True)
            End If
            Button1.Enabled = True
  
    End Select
    HttpUtils.Complete = False
End Sub

Sub RequestAddressesList
    ProgressDialogShow("Sending addresses list request...")
    HttpUtils.Download("AddressesList", AddressesListLink & "?access_token=" & AccessToken & "&v=3.0&max-results=100")
    Msgbox("Got Right Here"  , "")
End Sub

Sub XML_StartElement (Uri As String, Name As String, Attributes As Attributes)
  
End Sub
Sub XML_EndElement (Uri As String, Name As String, Text As StringBuilder)
    If Name = "fullName" Then
        ListView1.AddSingleLine(Text.ToString)
    End If
End Sub

I dont understand was exactly the question is. Can you explain more detailed what your goal is or what you want to know? Maybe it would help me if you find simpler instructions/question cause i did not understand what you want to do. My english sucks sometimes (I´m german) ;)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
If i understand correctly. The RequestAddressesList is your problem. You have the auth-code but then you want to get adressdata, right? And you want to do it with httputils2 (Job), right?

If yes then i would say:

Have you tried it this way?

B4X:
Sub RequestAddressesList
  ProgressDialogShow("Sending addresses list request...")
  'HttpUtils.Download("AddressesList", AddressesListLink & "?access_token=" & AccessToken & "&v=3.0&max-results=100")
    Dim job As HttpJob
    job.Initialize("AddressesList", Me)
    job.download( AddressesListLink & "?access_token=" & AccessToken & "&v=3.0&max-results=100")
  Msgbox("Got Right Here"  , "")
End Sub

And in jobdone you should get the json you want to parse. Or not?
 
Upvote 0

young61

Member
Licensed User
Longtime User
Yes, RequestAddressesList has been a problem, but I also want to redo the way I get the Access Token. I want to use httputils2 for that as well.
 
Upvote 0

young61

Member
Licensed User
Longtime User
What is the equivalent in httputils2 as the following code:

B4X:
Dim postString AsString'Msgbox("postString ","")
postString = "grant_type=authorization_code&code=" & AuthorizationCode & "&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client_id=" & clientId & "&client_secret=" & clientSecretMsgbox("postString " & postString & "","")
 HttpUtils.postString("GetAccessToken", "https://coinbase.com/oauth/token", postString)

and this

Dim url AsString
url = HttpUtils.Tasks.Get(0)
If HttpUtils.IsSuccess(url) ThenDim parser AsJSONParser
   parser.Initialize(HttpUtils.GetString(url))
 
Upvote 0
Top