android - 我无法使用 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){
}
}
}
解决方案
我将从 AppAuth 代码示例开始。我的博客文章 有关于如何运行它的分步说明。
一旦它工作,重新配置它以指向您自己的授权服务器。
推荐阅读
- smtp - smtp状态码数字和数字点分码的含义
- javascript - 基于返回不同输出的数组元素
- javascript - 在 catch 函数中,返回了一个被拒绝的承诺,但没有返回一个已解决的承诺?
- excel - 在 PhpSpreadsheet 中创建 excel 文件时如何计算公式
- php - 如何在 laravel eloquent 中按相关表的列排序?
- python-3.x - 将 Python 石墨烯与 Apollo Federation 集成的问题
- mysql - MySQL中生成的列中的日期时间错误
- sql - 如何标记每月至少有一笔交易的活跃客户?
- django - 在 FE 上下载/引用期间是否可以交换 FileField 的文件名?
- java - Spring-boot 中 ConditionalOnBean 的意外行为