G
G
Grems2019-07-03 20:42:00
Android
Grems, 2019-07-03 20:42:00

How to perform Oauth 2.0 authorization on android without third-party libraries?

As after receiving the authorization token by this method:

public void getAuthToken(Account account, final OAuthCallbackListener authCallbackListener) {
    accountManager.getAuthToken(account, SCOPE, null, act,
        new AccountManagerCallback<Bundle>() {
            public void run(AccountManagerFuture<Bundle> future) {
                try {
                    String token = future.getResult().getString(AccountManager.KEY_AUTHTOKEN);
                    authCallbackListener.callback(token);
                /* 
                     Intent launch = (Intent) future.getResult().get(AccountManager.KEY_INTENT);
                     if (launch != null) {
                     act.startActivityForResult(launch, 0);
                     return;
                     }

                     //*/

                    } catch (OperationCanceledException e) {
                    authCallbackListener.callback(null);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, null);
}

, then exchange it for access_token and refresh_token, without using third-party libraries.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rasul Kakushev, 2019-07-03
@Raserad

In short, you must make a get or post request containing your token to the server and process the result that came from it. I just can't figure out where you log in? After all, for different services, authorization methods are different.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question