如何在 Play Developer API 中获取 access_token 以回复评论? [英] How to get access_token for replying review in Play Developer API?

查看:24
本文介绍了如何在 Play Developer API 中获取 access_token 以回复评论?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此链接:

但是转到链接后,我没有找到太多关于此的信息,而是它有另一个链接将我带到我已经创建服务帐户的页面.

总结后,我的问题是 - 我创建了一个服务帐户并将密钥下载为 JSON.但是如何获得这个 access_token 给定的快照要求呢?JSON文件本身不包含这样的access_token,而是包含其他信息,包括type、project_id、private_key、c​​lient_id等.

解决方案

问题中给出的链接中没有直接描述该过程.相反,我们将遵循 将 <..> 中的凭据(包括 <>)替换为我们目前收集的信息.这里的<上一步的代码>就是我们得到的代码参数4/eWdxD7b-YSQ5CNNb-c2iI83KQx19.wp619.....

  • 现在进行这个 API 调用.要进行这种 API 调用,您可能需要使用 此外,您无需更改 grant_type(其值为 authorization_code).

  • 现在单击Send,您应该会收到包含access_token 的响应.以下是我们正在寻找的 access_token 附带的响应的快照(快照来自文档):

  • 此响应只会出现一次(对于某个 code),要获得另一个响应,您可能需要另一个 code.因此,将此响应保存为 Postman 中的 JSON 以进一步使用它.

  • 现在你已经完成了!使用此 access_token 并进行 API 调用以获取对评论的回复.更多详情这里.另请注意,您可能不会通过此电话获得任何评论,因为 this 评论的回复仅适用于近期.如果您最近在 Play Store 中您想要的应用下发表了一些评论,它们将被返回,但较旧的评论不会作为响应返回,并且响应可能是空白 {} 如果最近没有评论.如文档中所述:

    <块引用>

    注意:您只能检索用户在上周创建或修改的评论.如果您想检索自一开始以来对您的应用的所有评论,您可以使用 Google Play 管理中心将您的评论下载为 CSV 文件.

    This link:

    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.

    这篇关于如何在 Play Developer API 中获取 access_token 以回复评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆