PrashanthKumar123
New Member
- Joined
- May 1, 2021
- Messages
- 38
Hi - I have an Excel tool with VBA code and I'm looking to connect with Splitwise API now. I'm stuck at Oauth authentication and looks like VBA is ill suited for Oauth.
I've setup redirect url on Splitwise as Example Domain. Chrome browser launches Splitwise and allows user to login and provide consent to my tool. Post this, the user is redirected to the redirect url along with the Oauth code and state. I'm struggling to get this code and state in VBA. Is there a way to do this?
I have a second code to use this code and send a POST request to fetch final Oauth token.
consumer_key = {my consumer key}
consumer_secret = {my consumer secret}
request_token_url = "https://secure.splitwise.com/oauth/request_token"
accesstoken_url = "https://secure.splitwise.com/oauth/access_token"
authorize_url = "Log in"
Set API_Call2 = CreateObject("MSXML2.serverXMLHTTP.6.0")
API_Call2.Open "POST", authorize_url & "?redirect_uri=https://www.example.com/&response_type=code&client_id={my consumer key}&client_secret={my consumer secret}", False
API_Call2.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
API_Call2.send
Shell "explorer ""Log in{my consumer key}&client_secret={my consumer secret}"""
Debug.Print API_Call2.responseText()
Debug.Print API_Call2.getAllResponseHeaders()
End Sub
I've setup redirect url on Splitwise as Example Domain. Chrome browser launches Splitwise and allows user to login and provide consent to my tool. Post this, the user is redirected to the redirect url along with the Oauth code and state. I'm struggling to get this code and state in VBA. Is there a way to do this?
I have a second code to use this code and send a POST request to fetch final Oauth token.
consumer_key = {my consumer key}
consumer_secret = {my consumer secret}
request_token_url = "https://secure.splitwise.com/oauth/request_token"
accesstoken_url = "https://secure.splitwise.com/oauth/access_token"
authorize_url = "Log in"
Set API_Call2 = CreateObject("MSXML2.serverXMLHTTP.6.0")
API_Call2.Open "POST", authorize_url & "?redirect_uri=https://www.example.com/&response_type=code&client_id={my consumer key}&client_secret={my consumer secret}", False
API_Call2.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
API_Call2.send
Shell "explorer ""Log in{my consumer key}&client_secret={my consumer secret}"""
Debug.Print API_Call2.responseText()
Debug.Print API_Call2.getAllResponseHeaders()
End Sub