A antsnel Member Licensed User Longtime User Jun 25, 2018 #1 Hi How do pass the token when using PutString with oAuth2? e.g. Dim j As HttpJob j.Initialize("", Me) j.PutString("https://sheets.googleapis.com/v4/spreadsheets/1oQ ... ") How do you add the token to the put request ?
Hi How do pass the token when using PutString with oAuth2? e.g. Dim j As HttpJob j.Initialize("", Me) j.PutString("https://sheets.googleapis.com/v4/spreadsheets/1oQ ... ") How do you add the token to the put request ?
Erel B4X founder Staff member Licensed User Longtime User Jun 26, 2018 #2 Please use [code]code here...[/code] tags when posting code. Google OAuth2 tutorial: [class][B4X] Google OAuth2 antsnel said: How do you add the token to the put request ? Click to expand... It depends on the specific web service you are calling. Upvote 0
Please use [code]code here...[/code] tags when posting code. Google OAuth2 tutorial: [class][B4X] Google OAuth2 antsnel said: How do you add the token to the put request ? Click to expand... It depends on the specific web service you are calling.
A antsnel Member Licensed User Longtime User Jun 26, 2018 #3 Hi Erel, Thanks for the reply I can download data from a Google Sheet using your oAuth2 example, I am now trying to update the same spreadsheet - it also seems I should use PostString and not PutString as per my previous attempt. API call is documented here: https://developers.google.com/sheets/api/guides/values#writing_to_a_single_range Assuming my token is valid and stored in a variable called token, I need to know how to append the token to this API call when doing a Post or Put (I am also assuming this specific API endpoint supports it) Thanks Upvote 0
Hi Erel, Thanks for the reply I can download data from a Google Sheet using your oAuth2 example, I am now trying to update the same spreadsheet - it also seems I should use PostString and not PutString as per my previous attempt. API call is documented here: https://developers.google.com/sheets/api/guides/values#writing_to_a_single_range Assuming my token is valid and stored in a variable called token, I need to know how to append the token to this API call when doing a Post or Put (I am also assuming this specific API endpoint supports it) Thanks
K keirS Well-Known Member Licensed User Longtime User Jun 26, 2018 #4 Google allow two ways to pass an access token. Either as a query parameter with ?access_token=YourAccessToken or as an HTTP Authorization header: "Authorization: Bearer oauth2-token" I always use the header but this is counter intuitive in B4A as you set the header after you call PostString. See https://www.b4x.com/android/forum/threads/set-http-request-header-with-httputils2.39413/#content for an example. Upvote 0
Google allow two ways to pass an access token. Either as a query parameter with ?access_token=YourAccessToken or as an HTTP Authorization header: "Authorization: Bearer oauth2-token" I always use the header but this is counter intuitive in B4A as you set the header after you call PostString. See https://www.b4x.com/android/forum/threads/set-http-request-header-with-httputils2.39413/#content for an example.
A antsnel Member Licensed User Longtime User Jul 1, 2018 #5 Thanks - I passed the token successfully as a query string , however I found you'll also need to tell the Google Sheets API that your submitted data is json: Code: Copy j.GetRequest.SetContentType("application/json") Upvote 0
Thanks - I passed the token successfully as a query string , however I found you'll also need to tell the Google Sheets API that your submitted data is json: Code: Copy j.GetRequest.SetContentType("application/json")