---
title: "Google AuthenticationException: 403: Invalid AuthSub token"
author: "wangcheng"
date: "2010-08-06T23:04:30Z"
tags: []
categories: ["互联网"]
slug: "google-authenticationexception-403-invalid-authsub-token"
draft: false
lastmod: "2010-08-06T23:04:30Z"
id: 731341
url: "https://wangcheng.iteye.com/blog/731341"
---

给客户的网站做了Google Authentication认证，一直都好用的，这几天突然注册不上新用户了

 

```
com.google.gdata.util.AuthenticationException: 403: Invalid AuthSub token.
        at com.google.gdata.client.http.AuthSubUtil.exchangeForSessionToken(AuthSubUtil.java:309)
        at com.google.gdata.client.http.AuthSubUtil.exchangeForSessionToken(AuthSubUtil.java:275)

```

 

代码没改过，证书也没变，Googling

 

http://www.google.com/support/forum/p/apps-apis/thread?tid=16306d02c282e8d3&hl=en

 

只要添加 URLDecoder.decode 就可以了

 

```
	String token = request.getQueryString();
	String oneTimeUseToken = AuthSubUtil.getTokenFromReply(token);
	oneTimeUseToken = URLDecoder.decode(oneTimeUseToken, "UTF-8");
	String sessionToken = AuthSubUtil.exchangeForSessionToken(oneTimeUseToken, privateKey);
```

 

 

参考

 

http://code.google.com/intl/fr/apis/gdata/docs/auth/authsub.html

 

http://code.google.com/intl/fr/apis/gdata/docs/auth/overview.html