首页 > 解决方案 > 我无法使用 oauth 2.0 与我的服务器使用 android 连接

问题描述

我是 android 新手,我需要使用 oauth 2.0 连接服务器我需要的只是正确获取令牌我希望我的问题很清楚
谢谢你
这是我所做的

AccountManager am = AccountManager.get(Authentification.this);
            Bundle options = new Bundle();
            options.putSerializable("numero", numero);
            
            am.getAuthToken(
                    null,
                    "whrite",
                    options,
                    this,
                    new OnTokenAcquired(),
                    null);

private class OnTokenAcquired implements AccountManagerCallback<Bundle> {
    @Override
    public void run(AccountManagerFuture<Bundle> result) {
        // Get the result of the operation from the AccountManagerFuture.
        try{
            Bundle bundle = result.getResult();

            // The token is a named value in the bundle. The name of the value
            // is stored in the constant AccountManager.KEY_AUTHTOKEN.
            String token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
    System.out.println("================>>>>"+token);

        }catch(Exception e){

        }

    }
}

标签: androidoauth-2.0

解决方案


我将从 AppAuth 代码示例开始。我的博客文章 有关于如何运行它的分步说明。

一旦它工作,重新配置它以指向您自己的授权服务器。


推荐阅读