问题
I'm using Retrofit library and I wanted to implement OAuth 2.0 on every API call in order to authenticate those calls. How can I achieve that? Can you explain me step by step? I have followed some blogs but didn't understand how to do that.
回答1:
I highly recommend you to check u2020 source code. You can achieve this with a OkHttp interceptor (Retrofit 1.x or Retrofit 2.x) or a RequestInterceptor if you stay with Retrofit 1.x.
回答2:
I think for the oAuth 2.0 process its better if you open directly the browser and once its done it will redirect to the redirect_url specified. You will need to register the redirect_url in your manifest as a intent-filter for the activity that will manage the response of the server.
来源:https://stackoverflow.com/questions/32624703/how-to-oauth-2-0-with-retrofit-android