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

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

问题描述

此链接:

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

总结之后,我的问题是-我创建了一个服务帐户并将密钥下载为JSON.但是如何在给定的快照要求下获取此 access_token ?JSON文件本身不包含此类access_token,而是包含其他信息,包括类型,project_id,private_key,client_id等.

解决方案

在问题给出的链接中没有直接描述该过程.相反,我们将按照用到目前为止收集到的信息替换< ..> 内部的凭据(包括< > ).此处<上一步中的代码> 只是代码参数 4/eWdxD7b-YSQ5CNNb-c2iI83KQx19.wp619 .... .

  • 现在进行此API调用.要进行此类API调用,您可能需要使用同样,您无需更改 grant_type (其值为 authorization_code ).

  • 现在单击 Send ,您应该得到包含 access_token 的响应.以下是我们正在寻找的 access_token 随附的响应的快照(从文档中获取的快照):

  • 此响应只会出现一次(对于特定的 code ),要获得其他响应,您可能需要另一个 code .因此,请将此响应另存为来自 Postman JSON ,以便进一步使用.

  • 现在您完成了!使用此 access_token 并进行API调用以回复评论.更多详细信息此处.另请注意,此呼叫可能根本不会获得任何评论,例如评论的回复仅适用于最近时间.如果您在所需应用程序下的 Play商店中发表了一些近期评论,则将返回这些评论,但较旧的评论将不会作为响应返回,并且如果以下情况,响应可能为空白 {} 没有最新评论.如文档中所述:

    注意:您只能检索用户在上周内创建或修改的评论.如果您想检索自开始以来应用程序的所有评论,则可以使用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.

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

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