Android Question Google play developer API question

tufanv

Expert
Licensed User
Longtime User
Hello,

Following this tutorial : https://www.b4x.com/android/forum/threads/google-play-developer-api.81839/#content

on stackoverflow, someone wrote : "The access_token expires after one hour of exchange you so need some server code to handle this and Google have provided several libraries in many languages to handle this (list not exhaustive):"

My question is : should we run the server app described in Erel's tutorial on a vps so that token is updated every hour ? because I need to check users inventory on every user logon to my app ?

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
yes.
As it uses the OAuth2 Class i expect it to work on a VPS. Means the Serverapp should be able to refresh the token if needed.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
I have now changed the parameters on both server and client apps and it seems to work. But the server was local. What confuses me is if I upload this jar to my vps , will I need to leave it running or will I have to run it every 30 minutes for example to update the token ? second one seems more reasonable to me. Also where will i instruct my b4a app to interact with the server , or don't I need to interact with the server again ? So confusing for just to validate some inapp purchases.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
1. You always should create a new thread for a new Question.
2. It is a server app which is expected to run all the time to be able to answer client-requests.
3. As it is using the OAuth-Class it should be able to get a Token (even if the token is expired and a client connect to the server, the server then want to use the Token. If the token is expired then the OAuth Class will get a new one based on the refresh-token stored.
B4X:
    oauth2.GetAccessToken
    Wait For OAuth2_AccessTokenAvailable (Success As Boolean, Token As String)
    If Success = False Then
        Log("Error accessing account.")
        Return
    End If
    ' use the token here ....

I can´t answer any question about InApp-Purchases in detail; i do not have any single app using InAppPurshase.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
If the token is expired then the OAuth Class will get a new one based on the refresh-token stored.
from OAuth-Class
B4X:
Public Sub GetAccessToken
    If ti.Valid = False Then
        Authenticate
    Else if ti.AccessExpiry > DateTime.Now Then
        GetTokenFromRefresh
    Else
        RaiseEvent(True)
    End If
End Sub
 
Upvote 0
Top