Customer id, secret, etc. true. I double-checked them. Google + works, and I also get an access token, but when I try to use the YouTube YouTube video rating, it gives 403 forbidden errors in real devices. However, it works great in a simulator. What is the problem here? Can anyone help? Any help is appreciated. Thankyou
PS Before I did not use "gc.setScope" (" https://www.googleapis.com/auth/youtube.force-ssl "), this line in the code gives the same forbidden error in the simulator as well, but Now I added a line and it works in the simulator, but it gives a 403 forbidden error in real devices.
sign.addActionListener((e) -> {
String clientId = "873649282964-7r6088ua0jhoua2tngpblhf4u8elda55.apps.googleusercontent.com";
String redirectURI = "https://www.youtube.com/";
String clientSecret = "_T7cyd-kWQKDzH0ZwiIeq1jr";
gc = GoogleConnect.getInstance();
gc.setClientId(clientId);
gc.setRedirectURI(redirectURI);
gc.setClientSecret(clientSecret);
gc.setScope("https://www.googleapis.com/auth/youtube.force-ssl");
gc.setCallback(new LoginCallback() {
@Override
public void loginFailed(String errorMessage) {
System.out.println("errorMessage");
}
@Override
public void loginSuccessful() {
System.out.println("login success");
}
});
if (!gc.isUserLoggedIn()) {
gc.doLogin();
} else {
token = gc.getAccessToken().getToken();
}
});
Button like = new Button("Like");
likeForm.add(like);
like.addActionListener((e) -> {
token = gc.getAccessToken().getToken();
ConnectionRequest cr = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
super.readResponse(input);
}
@Override
protected void postResponse() {
like.setText("Like: " + "ok");
}
};
cr.setPost(true);
cr.setUrl("https://www.googleapis.com/youtube/v3/videos/rate?id=" + "lIHr4ZVMBoo" + "&rating=like&access_token="+ token);
System.out.println("geturl " + cr.getUrl());
cr.setDuplicateSupported(true);
NetworkManager.getInstance().addToQueueAndWait(cr);
});
Error Log:
04-15 08:05:10.761: E/GMPM(5344): getGoogleAppId failed with status: 10
04-15 08:05:10.761: E/GMPM(5344): Uploading is not possible. App measurement disabled
04-15 08:06:02.901: E/Volley(2900): [154] BasicNetwork.performRequest: Unexpected response code 403 for https://www.googleapis.com/plus/v1/people/me