XiaoCongGame / sdk-smart-lib

The Android library project for Xiaocong SDK
0 stars 1 forks source link

Doc: How can I tell if accessToken is expired? #8

Closed thedmd closed 10 years ago

thedmd commented 10 years ago

How can I tell if accessToken is expired and user should go trough login process again?

ReDreamport commented 10 years ago

If accessToken is expired, the SDK will hold the request, refresh token, then re-play it. Your app and users might not aware of it.

thedmd commented 10 years ago

So I should not worry about it and keep token once obtained during first sign in, right?

ReDreamport commented 10 years ago

We have cached the accessToken actually. We don't expose it by now because some guys don't use our signin/signup SDK and would like code them own one using our server API. But I think some improvement could be helpful too:

thedmd commented 10 years ago

I thought it was required. Can I assume SDK will prompt for user/pass when needed? Should I just call pay() method and not worry about presenting user 'register' and 'sign-in' buttons?

ReDreamport commented 10 years ago

It's not so easy to tell when the user/pass is needed. It depends on some circumstances such as payment way. Sometimes payment could be finished without signing in. Please give me some time to figure out whether it is practical.

thedmd commented 10 years ago

Right now, on my side I have AlertDialog asking user to use current account. screen2

If user choose to sign out this dialog will appear: screen3

Just before invoking payment app will ask to confirm purchase: screen4

I tried to be as informative as possible to avoid confusion from user.

Now, when I know accessToken is not required I'm not sure how to proceed. If SDK provide login window I will just remove those displayed by me and relay on your library to handle authentication.

thedmd commented 10 years ago

I just tested payment with authorization dialogs disabled and it failed with response: "message":"user is null","status":400}. It appears user has to be signed in anyway. If accessToken is cached after first call to pay() method is isn't really useful, because signing must be done anyway and retaining token isn't any problem after all.

ReDreamport commented 10 years ago

Sorry, the feature you demand is not pushed to this repo. Please sign in explicitly for the present. We will change the implementation soon and which won't break your codes.

thedmd commented 10 years ago

OK, I will keep my dialogs then.

ReDreamport commented 10 years ago

@thedmd We just submit version 0.9.1. There're some big changes. Now you don't need to care about user authentication any more. You could call payment API without checking user authentication first. We'll let users sign in if necessary after they choose a payment way. Refresh the token in SDK if they expire.

thedmd commented 10 years ago

Thank you for an update. I will look at changes and update update our code to match changes.