Answer the question
In order to leave comments, you need to log in
How to fix "client_id incorrect" error and get data from vk api?
You need to get data from this URL. I created a VK application, entered the ID of my application instead of client_id, and everything worked manually in the browser:
https://oauth.vk.com/authorize?client_id=1&display=page&redirect_uri=http://example.com/callback&scope=friends&response_type=token&v=5.131
@SpringBootApplication
public class BlogApplication {
private static final Logger log =
LoggerFactory.getLogger(BlogApplication.class);
public static void main(String[] args) {
SpringApplication.run(BlogApplication.class, args);
RestTemplate restTemplate = new RestTemplate();
Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("client_id", "Здесь мой id, палить не буду, но он написан правильно 100%");
uriVariables.put("display", "page");
uriVariables.put("redirect_uri", "http://vk.com");
uriVariables.put("scope", "friends");
uriVariables.put("response_type", "token");
uriVariables.put("v", "5.131");
Access access = restTemplate.getForObject("https://oauth.vk.com/authorize", Access.class, uriVariables);
log.info(access.toString());
}
}
@JsonIgnoreProperties
public class Access {
private Long token;
private String expiresIn;
private String userId;
public Access() {}
public Long getToken() {
return token;
}
public void setToken(Long token) {
this.token = token;
}
public String getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(String expiresIn) {
this.expiresIn = expiresIn;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
@Override
public String toString() {
return "Access [expiresIn=" + expiresIn + ", token=" + token + ", userId=" + userId + "]";
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question