I would like to update my application's Dropbox support from using the short lived (4 hour) access toke to using the refresh token to allow long term access.
I have located a Dropbox example that works but uses a curl command to get the refresh token which I am trying to move to B4i
The following curl command works to get a "Refresh Token" when entered into a Windows Terminal once you have the Authorization code.
(In this example I have replace the valid "code" and client_id:secret with placeholders. Where Dropbox app key = aaaaa... and secret= sssss...)
Using the following website I converted the curl command to HTTP.
I have located a Dropbox example that works but uses a curl command to get the refresh token which I am trying to move to B4i
The following curl command works to get a "Refresh Token" when entered into a Windows Terminal once you have the Authorization code.
(In this example I have replace the valid "code" and client_id:secret with placeholders. Where Dropbox app key = aaaaa... and secret= sssss...)
Now I just need to convert that to code into something I can put into my B4i app.curl https://api.dropbox.com/oauth2/token -d code=1234567890123456789012345678901234567890123 -d grant_type=authorization_code -u aaaaaaaaaaaaaaa:sssssssssssssss
Using the following website I converted the curl command to HTTP.
I then then tried to convert that to the following B4i code. But when executed in a not so helpful "request completed with error" from Dropbox.POST /oauth2/token HTTP/1.1
Host: api.dropbox.com
User-Agent: curl/8.2.1
Accept: */*
Authorization: Basic YWFhYWFhYWFhYWFhYWFhOnNzc3Nzc3Nzc3Nzc3Nzcw==
Content-Type: application/x-www-form-urlencoded
Content-Length: 78
code=1234567890123456789012345678901234567890123&grant_type=authorization_code
Could someone point out what I am doing wrong in this code? Thanks.Dim auth_code as string = "1234567890123456789012345678901234567890123"
Dim job As HttpJob
job.Initialize("get_refreshtoken",Me)
job.PostString("https://api.dropbox.com/oauth2/token","code="&auth_code&"&grant_type=authorization_code")
job.GetRequest.SetHeader("Authorization", "Basic YWFhYWFhYWFhYWFhYWFhOnNzc3Nzc3Nzc3Nzc3Nzcw==")
job.GetRequest.SetHeader("Content-Type", "application/json")
job.GetRequest.SetContentType("application/json")
job.GetRequest.SetContentEncoding("text/plain")
Last edited: