How can avoid Oauth 2.0 callbacks on Android
Am connecting an android app to Rails Oauth 2.0 Provider usi开发者_如何学Cng signpost lib. Each time i login, the app must be authorized vai a web browser launch. It is there a way to avoid?
You don't say, but it sounds like you're not caching your access token and secret. If you save these in a shared preference and use them to sign your requests next time your app runs, you should be able to skip the authentication stage and directly access the resources.
EDIT:
Thanks for the comment - once your user has authenticated, you can either have them enter a PIN into your application which you will then exchange for the access token and secret, or you must use the initial callback which actually just sends the PIN directly to you without user intervention.
So if you don't want your users to have to enter the PIN manually, you'll just have to use the callback. So long as the token remains valid you will never need to use the callback again.
If you are being forced to re-authorise your app each time you log in (as your question clearly states), then I can see four possibilities:
- You are not, in fact, caching your access token properly (or it is getting corrupted)
- Your token is becoming invalid very shortly after you log in (perhaps it's validity is very short)
- Your implementation is incorrectly taking you to the login page when in reality, it doesn't need to
- Your implementation is incorrectly requesting a new access token (thus invalidating the previous one - I had this particular bug that had me stumped for weeks in my app)
At this stage, I think you'll need to post some code so we can try to see where the problem may be.
精彩评论