当前位置: 动力学知识库 > 问答 > 编程问答 >

android - "Token expired" Obtaining Google Auth Token

问题描述:

I'm getting the following error back when trying to get a google auth token by using

AccountManagerFuture<Bundle> amf = am.getAuthToken(

accounts[0], "finance", null, activity[0], null, null

);

try

{

auth_token = amf.getResult().getString("authtoken");

Log.v("PORTFOLIO", "getting token...: "+auth_token);

}

catch (Exception e)

{

e.printStackTrace();

}

I get a valid-looking token, but then when I try and use it, I get a "Token expired" error back:

V/PORTFOLIO(11970): <HTML>

V/PORTFOLIO(11970): <HEAD>

V/PORTFOLIO(11970): <TITLE>Token expired</TITLE>

V/PORTFOLIO(11970): </HEAD>

V/PORTFOLIO(11970): <BODY BGCOLOR="#FFFFFF" TEXT="#000000">

V/PORTFOLIO(11970): <H1>Token expired</H1>

V/PORTFOLIO(11970): <H2>Error 401</H2>

V/PORTFOLIO(11970): </BODY>

V/PORTFOLIO(11970): </HTML>

Along with:

W/DefaultRequestDirector(11970): Authentication error: Unable to respond to any of these challenges: {googlelogin=WWW-Authenticate: GoogleLogin realm="http://www.google.com/accounts/ClientLogin", service="finance"}

I'm a little confused why this is happening, as it was working properly before. How do I get a "non-expired" token? I'm probably doing something terribly wrong. If anyone has a link to a proper auth token tutorial, that would help too.

网友答案:

Looks like I need to use invalidateAuthToken().

分享给朋友:
您可能感兴趣的文章:
随机阅读: