需要获得授权才能从Google Play开发者API获取信息。
我知道如何使用Postman进行此操作,但是实现授权要麻烦得多(重定向URL,处理重定向等),这些步骤就是您已经在Google Developer API Console中设置auth数据的步骤。
1.) GET https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=http://www.myurl.com/oauth2callback&client_id=1234567890.apps.googleusercontent.com
2.) get code which was sent to redirect url.
3.) POST https://accounts.google.com/o/oauth2/token
with
grant_type:authorization_code
code:[the code I got before]
client_id:1234567890.apps.googleusercontent.com
client_secret:[my client secret]
4.) Invoke GET https://www.googleapis.com/androidpublisher/v2/applications/packageName/purchases/subscriptions/subscriptionId/tokens/token
with:
Scope: https://www.googleapis.com/auth/androidpublisher
and:
access_token as query parameter I got before.
Run Code Online (Sandbox Code Playgroud)
现在,我要以编程方式完成所有这些操作。显然不是那么容易。我以为Google API客户端库会有所帮助,但我看不到这些库如何为我的用例提供帮助。
例如,像GoogleAuthorizationCodeFlow之类的类在请求时希望有一个用户ID,但现在不一定要有一个用户ID,因此我想知道如何以一种干净的方式使用此API。
有没有一种干净的方法可以通过一些API来更轻松/以编程方式处理OAuth2.0,以访问Google Play开发者API?否则,我必须手动实现它。
google-api google-oauth google-oauth-java-client google-oauth2