I need to get an access_token + refresh token for a specific user via the remote HTTP service function of DF.
at first, my scenario:
-my mobile app start's the authorization grant flow and get's an authorization code from google
-the app passes this code to my df remote http service endpoint
-the endpoint recieves the request and should add client_id, client_secret etc. to the request body
-the endpoint forwards the request to google oauth token endpoint and should get an access_token, refreshtoken etc back as response.
As google only accepts application/x-www-form-urlencoded data, I need to change the request into this format.
My questions are:
-Is it possible to see the whole request that DF sends to Google?
-Is it possible to transform the request body into the right format? I think that is not done automaticly by DF
In curl, it looks like this:
-d code=4/LjNMkGqqQvJAB96Z6F-U52u4kqo5RHkqLp0LJYZ-zAw \
-d client_id=807080008535-9ji0g54v0lt9b6ukn19rp807k3j2t0uj.apps.googleusercontent.com \
-d client_secret=SOMESECRET \
-d redirect_uri=http://localhost \
-d grant_type=authorization_code https://www.googleapis.com/oauth2/v4/token
client_id, client_secret, redirect_uri and grant_type are set in the remote http service config with these values and the outbound option,
the code is sent from the mobile app to the remote http service endpoint and should be appended to the request.
I already got this scenario working properly with Fitbit OAuth. But Google might be more difficult.
Now DF sends the request trough a proxy, so I can see what exactly gets sent to google.
If DF send's the token request to google, it fails with 'invalid_grant' 'Bad Request'
If I send it via curl manually, it succeeds.
The proxy shows that ALL parameters are exactly the same.
I got this working!!
The problem was the redirect URI.
I chose 'com.fitisfit.app:/googlefit', that didn't work, I dunno why.
Changed it to just 'com.fitisfit.app:' without a path at the end, that worked, I dunno why either.