How to get access_token for replying review in Play Developer API? - google-play

This link: Reply to Reviews describes the way to retrieve and reply to reviews. The Google Play Developer Reply to Reviews API allows us to view user feedback for our app and reply to this feedback. But I am finding it difficult to get the authorization token. It says I should have got this when I get access to the API.
But after going to the link, I didn't find too many information on this, rather, it has another link which takes me to the page where I have already created a service account.
After summarizing, my question is - I have created a service account and downloaded the key as JSON. But how to get this access_token the given snapshot asking for? The JSON file itself doesn't contain such access_token, rather it contains other information including type, project_id, private_key, client_id etc.

The process is not described directly in the link given in the question. Rather we will follow the steps mentioned in Play Developer API | Authorization
The whole process actually has two major steps:
Making a OAuth 2.0 client ID and downloading it.
Using client_id, client_secret and redirect_uris from this download JSON file to make API call.
Making OAuth 2.0 client ID and getting parameters
In order to do this:
Go to Google Play Console.
Use your play console account to login into it.
Make sure the right project is selected, at top there is a drop-down, where the correct project is supposed to be selected.
Now from + CREATE CREDENTIALS button create a OAuth Client ID and after successful creation you will find it listed under Credentials tab. The Credentials tab is at the left side of the page.
Now download the OAuth Client ID and it will be saved as a JSON file.
Open the JSON file and collect the client_id, client_secret and redirect_uris from there. Here redirect_uris will contain a list of URLs. One of them is http://localhost, we don't need it. Please take the other one, somewhat like urn:ietf:wg:oauth:2.0:oob.
Now the second step begins:
Make the API call
Now go to the first link I provided in the answer, i.e: Play Developer API | Authorization. We just did the first step under initial configuration. Now the second step begins. Make sure you are using the same browser where you are already logged-in on Google Play Console.
Now fill-up the fields in this link as mentioned in the documentation
with the information we just got (client_id, client_secret,
redirect_uris), remove the ... and put your redirect_uri and
client_id there:
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=...&client_id=...
Now after filling up your credentials in this link provided paste this link to browser and go to this URL.
This may require you to authorize this request by signing in with your account (with the Google Play Console Account we are using so far).
After authorization you will be given a code parameter similar to 4/eWdxD7b-YSQ5CNNb-c2iI83KQx19.wp619..... (This is also mentioned in the documentation you may follow the steps there).
Now go to the step 4 in the documentation (following is a snapshot):
replace the credentials which are here inside <..> (including < and >) with the information we so far collected. Here <the code from the previous step> is nothing but the code parameter 4/eWdxD7b-YSQ5CNNb-c2iI83KQx19.wp619.... we got.
Now make this API call. To make this kind of API calls you may need to use Bulk edit of Postman software (download and install the software). But if you are not comfortable with this Bulk edit, I am giving you a similar form data in the following snapshot. Just fill up the fields there in Postman and make the API call, (Please note that the method is selected POST):
Also you need not change the grant_type (its value is authorization_code).
Now clicking Send you should get the response which will contain access_token. Following is a snapshot of the response that comes with the access_token we are looking for (snapshot got from the documentation):
This response will come only once (for a certain code), to get another response you may need another code. So, save this response as a JSON from Postman to use it further.
Now you are done! Use this access_token and make API calls to get reply to reviews. More details here. Also please note that you might not get any reviews at all with this call, as this reviews' responses only work for recent time. If you make some recent comment in Play Store under your desired app they will be returned but the older comments will not be returned as response and the response might be blank {} if there are no recent comments. As mentioned in the documentation:
Note: You can retrieve only the reviews that users have created or modified within the last week. If you want to retrieve all reviews for your app since the beginning of time, you can download your reviews as a CSV file using the Google Play Console.

Related

Single Sign On(-ish) behavior from MS Teams with BotFramework Composer

We are using BotFramework Composer to create bots. These bots are supposed to get information from a backend REST service, where we need to know, which user is submitting the request for data. We are currently using {turn.activity.from.id} to get the Teams user's id, and sending it in a special http header in the "Send an HTTP request" action. We then perform a mapping of this id to our internal users.
We are, of course, aware, that this is not secure at all, since anyone who knows this, could get the user's id and send it to our service. We are currently thinking along the lines of generating a short-lived jwt token in the Bot to send to our application. However, we see no direct way of implementing this token generation in the Bot Framework Composer itself.
Also, we don't want to use OAuth, because we don't want the user to have to log in via the bot.
Is there a way to implement custom token generation using C# or js and assigning it to a dialog variable to be used in a "Send an HTTP request" action?
This document discusses how to implement an HTTP request in Composer. The first half is focused on creating a login for OAuth, which I know is not your focus, so look at the second half. If you set up a simple server that can generate a token for you, then you can make a request to it from Composer using the method described.
As links can break and docs can change (and Composer is still in Preview), I would recommend saving the doc somewhere and checking back every so often for any updates.
I've used HTTP requests from within Composer, myself, so I know this will work for you.
Hope of help!
You can create a custom Action or a package component and create any c# methods there for JWT generation. This will keep it all local to the bot.
https://learn.microsoft.com/en-us/composer/how-to-create-custom-actions

Do I need to get API Key for Google Book search

I am little bit confused interpreting the Google Book API terms. In this page it is written that
Note: Performing a search does not require authentication, so you do
not have to provide the Authorization HTTP header with the GET
request. However, if the call is made with authentication, each Volume
will include user-specific information, such as purchased status.
Does that mean I don't need to use an API key for searching book info or linking cover from google books (to be used in Android App)?
Thanks
For searching only the informations about books (author, title, etc..) you can write code without have any API key. But probably for the payment service or other (write a book and insert that in google book api) you should have an API Key (with sign up).
Bye bye
For searching only the informations about books (author, title, etc..) you can write code without have any API key. But sometimes google books API gives back HTTP 403. HTTP Status Code 403: The server understood the request but refuses to authorize it. So it is advisable you use the API key generated and also try to mention your country code in it. As sometimes it fails to recognize where the request is coming from so it gives you access denied (403) error.
https://www.googleapis.com/books/v1/volumes?q=intitle:${bookTitle}&key=${googleKey}&country=${countryName}
This query was used by me in a React application as sometimes without key or country name i got HTTP 403 error. countryName is of the form US or UK, etc.

Feature or bug in the google url shortener depending on authentication method

If one calls the insert method while passing an api key on the request, then passing in a url like http://mostmedia.com/recent-projects always returns the same shortened url.
But if you authenticate using OAUTH then you get a new unique id for every long url you pass in, even when they are the same.
You can see this behavior in the api explorer when you toggle on and off OAUTH authentication:
https://developers.google.com/url-shortener/v1/url/insert
I don't see this documented anywhere, so it's hard to know whether this is a feature or a bug, or how we can expect it to behave in the future.
Does anyone know the official google line on this?
This is the intended behavior, see the section titled "Creating links when you’re signed in vs. signed out" on this doc: https://support.google.com/faqs/answer/190768 coped below:
Creating links when you’re signed in vs. signed out
Signed in
Your links are automatically added to goo.gl where you can track their
use.
A unique short URL is created each time a long URL is shortened.
Signed out
Your links won’t show up on your goo.gl page.
The same short URL is
reused each time a long URL is shortened by you or someone else.
That doc refers to the consumer product, but the behavior applies to the API as well. OAuth authentication is the API equivalent of being signed-in.
The reason a new short URL is returned on each call is so you can utilise multiple short-urls for tracking purposes.

how to call a Google API

I read the following two pages on Google:
1) https://developers.google.com/google-apps/documents-list/#getting_a_list_of_documents_and_files
and
2) https://developers.google.com/accounts/docs/OAuth2WebServer
I can go as far as getting an access_token (OAuth2) to be used in a subsequent Google API call (I want to call Google Docs Listing or Google Drive).
I wanted to use curl or something similar and just form my https URL.
- As such in the 1st document states to form a URL as follows:
https: //docs.google.com/feeds/default/private/full
- In the 2nd document, the example states to use something like https: //www.googleapis.com/oauth2/v1/userinfo?access_token=xxxxx
(adding the access token to the call)
Several questions
- Do I call googleapis.com or docs.google.com?
- can I call https: //docs.google.com/feeds/default/private/full?access_token=xxxxx
just add the access token to the call?
thanks
You need some effort to approach a Google API the first time, but then it's easy and elegant:
Manual preparation (One-time action): Sign in to Google, create a project, enable the API in question, create new Cient ID.
Get OAuth code, refresh token and access token (one-time action).
Make the API call (repetitive arbitrary actions).
Here is a detailed explanation of the entire process - Steps to make a Google API call.
A practical sample based on the Google Calendar API with full demo code in a single HTML file can also be reviewed here - Easy and compact access to my Google calendars.
The fastest way to get started is probably the quickstart guide for the Google Drive API, which shows how to setup your environment and write a complete command-line app to upload a file to Drive:
https://developers.google.com/drive/quickstart
Hie you can go through the Google Docs Sample Available Here
it's a command line smaple but this same thing you can implement in android. it works for me. you will find "docs-cmdline-sample" in repo. that will help you.

How can I log into gmail in a script/program using HTTPS?

My teacher has given me as an assignment to log into gmail and then send one e-mail or read the list of unread e-mails, but I can't use IMAP/POP3/SMTP or anything that isn't HTTP or HTTPS. I've tried looking for libraries in Ruby/Java to do it but nothing really worked for me.
I tried looking at the gmail source code page but I couldn't really understand what was going on. The page seems to call a post method on a link, but sniffing the packets what I saw was a GET apparently using a session generated using the info I send. So sending it "raw" didn't work either.
I've no idea what to do now.
After you authenticate with OAuth, you can get unread emails via an atom feed.
URL to hit: https://mail.google.com/mail/feed/atom/[<label>]
You can toy around with this at the Google oauth playground. Get an access token by continually clicking buttons and authenticating, and then hit discover feeds.
If you want a Java OAuth library, signpost is really good. You'll need to read the google documentation on its open authentication scheme. Specifically, you need to pass a scope query parameter when you attempt to authenticate. This is nonstandard, and it will trick you up if you're not looking for it.
If you're confused about OAuth or why its necessary, you may want to check out this resource.
Check out httplib2—it has (among other things) Google Account Authentication.

Resources