Ben yetkisiz duyuyorum bir hata alıyorum .. TEPKİ KOD 401
belirteç ben perl'de eserlerini kullanıyorum ..Java'da oauth2 çalışması için perl kodu yapmak ister "curl -H 'Yetkilendirme: Taşıyıcı: <TOKEN> https://canvas.instructure.com/api/v1";
Şu ana kadar denedim budur:
public static void main(String[] args) throws Exception {
try {
String auth = returnAuth(); //getting token from a file.
//System.out.println(auth);
String url1= "https://canvas.instructure.com/api/v1";
URL url = new URL(url1+"/courses");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
//connection.setRequestProperty("Authorization", "Bearer " + auth);
connection.setRequestProperty("Authorization", "Bearer "+auth);
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response code:" + connection.getResponseCode());
System.out.println("Response message:" + connection.getResponseMessage());
// Read the response:
BufferedReader reader = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String line;
StringBuffer response = new StringBuffer();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
System.out.println(response.toString());
}
catch (MalformedURLException e1) {
e1.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
}
o hata için üzgünüm. Ama kolon olmadan ve bir boşlukla denedim .. hala çalışmıyor – PrasadPatil
Simgesini nasıl oluşturduğunuzu sormalıyım - sınırlı bir ömrü vardır ve geçerli olmaları gerekir. İlk önce auth'u almak için Postman (https://www.getpostman.com/) Firebug (https://getfirebug.com/) gibi bir şey kullanmanızı önerebilirim ve * sonra Java kodunu çalıştırabilirim. – stdunbar
Yeni bir belirteç oluşturup çalışıp çalışmadığınızı ve öneri üzerinde çalışmayı deneyeceğim. Teşekkürler. – PrasadPatil