slack 国内 android,使用Slack Api登录,Android

我正在整合Slack Api: Sign in with Slack。我从Slack Api有几件事。使用Slack Api登录,Android

我需要的code参数。

在我的Activity班中,我为此使用WebView。要访问code参数,在shouldOverrideUrlLoading方法我用:

public boolean shouldOverrideUrlLoading(WebView view, String url) {

if (url.startsWith("http://localhost:8000/")) {

UrlQuerySanitizer urlQuerySanitizer = new UrlQuerySanitizer(url);

String CLIENT_CODE = urlQuerySanitizer.getValue("code");

Log.e(TAG, "shouldOverrideUrlLoading: "+ CLIENT_CODE);

loginPresenter.loginSuccess();

return true;

} else {

view.loadUrl(url);

return true;

}

}

我做类叫HttpConstant保持网址:

public class HttpsConstant {

public static final String AUTHORIZATION_SLACK_URL = "https://slack.com/oauth/authorize?scope=identity.basic,identity.email,identity.avatar&client_id=something";

public static final String TOKEN_URL = "https://slack.com/";

}

我做类叫StrngConstant保持这样:CLIENT_ID, CLIENT_SECRET, CLIENT_CODE。

public final class StringConstant {

public static final String CLIENT_ID = "something";

public static final String CLIENT_SECRET = "something" ;

public static final String CLIENT_CODE = "something but still does not

able to pass the code parameter here from my activity class";

}

我使用Retrofit为登录服务:

public interface LoginService {

@GET("api/oauth.access?client_id=" + StringConstant.CLIENT_ID +

"&client_secret=" + StringConstant.CLIENT_SECRET +

"&code="+ StringConstant.CLIENT_CODE)

Call getLoginToken();

}

我已经在shouldOverrideUrl方法使用SharedPreferences但无法使用尝试。

SharedPreferences preferences = getSharedPreferences("ClientCode", Context.MODE_PRIVATE);

SharedPreferences.Editor editor = preferences.edit();

editor.putString("Code", CLIENT_CODE);

editor.commit();

如何在登录服务中通过code参数?我怎样才能使用这个SharedPreferences,所以我可以访问code参数?或者,有没有其他方法可以获得code参数并使用它?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值