我一直在尝试解决这个问题一段时间,似乎无法接受我尝试过的任何事情。
我似乎无法检索刷新令牌,它会显示为空白。
public class oaUTH extends AsyncTask<Void, Void, Void> {
protected Void doInBackground(Void... unused) {
try {
JsonFactory jsonFactory = new JacksonFactory();
HttpTransport transport = new NetHttpTransport();
CredentialStore credentialStore = new SharedPreferencesCredentialStore(prefs);
AccessTokenResponse accessTokenResponse = credentialStore.read();
GoogleAccessProtectedResource accessProtectedResource = new GoogleAccessProtectedResource(accessTokenResponse.accessToken,
transport,
jsonFactory,
OAuth2ClientCredentials.CLIENT_ID,
OAuth2ClientCredentials.CLIENT_SECRET,
accessTokenResponse.refreshToken+"&access_type=offline");
final Latitude latitude = new Latitude(transport, accessProtectedResource, jsonFactory);
latitude.apiKey=OAuth2ClientCredentials.API_KEY;
Log.i("AGENTPORTAL", "Access Token = " + accessTokenResponse.accessToken + ", Expires in = " + accessTokenResponse.expiresIn + ", Refresh Token = " + accessTokenResponse.refreshToken + ", Scope = " + accessTokenResponse.scope);
LatitudeCurrentlocationResourceJson currentLocation = latitude.currentLocation.get().execute();
String locationAsString = convertLocationToString(currentLocation);
Log.i("TAG", locationAsString);
//textView.setText(locationAsString);
} catch (Exception ex) {
ex.printStackTrace();
//textView.setText("Error occured : " + ex.getMessage());
startActivity(new Intent().setClass(getApplicationContext(),OAuthAccessTokenActivity.class));
}
这是日志:访问令牌 = **AHES6ZTeqgwdxjll6Gb4Cf9I0_n5bO_OdgR2OR* *WLPCPzJ5xtO5M,过期时间 = 3599,刷新令牌 = ,范围 =
知道刷新令牌=“”在哪里吗?我添加了“&access_type=offline”,但仍然没有运气。任何帮助都深表感谢!