今天用java SDK 进行OAuth2遇到了两个问题:
1. The project was not built due to "Could not delete config.properties. Fix the problem, then try refreshing this project and building it since it may be inconsistent.
网上说要删除bin下所有的class文件再重新编译,其实这是因为bin和src文件夹下都有config.properties文件,修改了其中的一个却忘了修改另一个,这样造成文件不一致。只需要让两文件保持一致,再refresh一下project, 最后重新运行即可,如果还是不行则在修改了两个文件之后再restart一下eclipse即可;
2. "error":"invalid_grant","error_code":21325
这个问题是在获得了code,并在eclipse控制台下粘贴code按回车之后得到的授权错误。调试了一天,后来发现是在config.properties文件中的redirect_URI的问题,之前在SAE注册了账号并创建了一个应用,我把redirect_URI设置成SAE应用的地址便出现了如上错误,后来我把redirect_URI设置成http://www.baidu.com之后就能顺利在eclipse控制台获取到accessToke。
在这里留个记号,并希望对别人有所帮助。