Arkadaşlar merhaba, bu konularda çok tecrübeli değilim, bu yüzden ChatGPT'den destek alarak böyle bir POST isteği oluşturdum. Her şeyin doğru olduğuna eminim ama "Giriş Yap" dediğimde hata mesajı bile almıyorum.
Kodun açıklaması şu şekilde: Snapfish hesabına giriş yapıyor, hesabın access_token ve id bilgilerini alıyor, bu bilgileri ayrıştırıyor. Ardından, bu token ile tekrar bir istekte bulunup kullanıcının Google Fotoğraflar ile bağlantılı kütüphanesine giriş yapması gerekiyor. Ancak, istediğim gibi çalışmadı. Acaba kodda hata mı var? Yardımcı olabilir misiniz?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery POST Requests with Form</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h1>Snapfish OAuth</h1>
<form id="loginForm">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Login</button>
</form>
<script>
$(document).ready(function() {
$('#loginForm').on('submit', function(event) {
event.preventDefault();
var username = $('#username').val();
var password = $('#password').val();
// İlk POST isteği
$.ajax({
url: "https://accounts.snapfish.com/v1/oauth2",
type: "POST",
contentType: "application/x-www-form-urlencoded",
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
"Pragma": "no-cache",
"Accept": "*/*"
},
data: {
password: password,
client_secret: "e12ada6a819a4cf09c6ed3ae4b0d77c1",
client_id: "151c8b4118a44d96a7f457365deda636",
username: username,
context: "/hp/sf/sf-uk/snapfish-uk",
grant_type: "password",
verbose: ""
},
success: function(response) {
var accessToken = response.access_token;
var accountId = response.accountId;
// İkinci POST isteği
$.ajax({
url: "https://www.snapfish.com/library/request_api",
type: "POST",
contentType: "application/json",
headers: {
"authorization": "OAuth " + accessToken,
"gsid": "aus-7c262cd8-4cf0-46dd-8cae-02307d7954d7-35394"
},
data: JSON.stringify({
version: "v1",
type: "GET",
req_service: "pascal",
url: "/v1/gw/snapfish/oauth/google/refreshToken?accountId=" + accountId + "&dataCenter=AUS"
}),
success: function(response) {
console.log("Second request successful:", response);
},
error: function(error) {
console.error("Second request failed:", error);
}
});
},
error: function(error) {
console.error("First request failed:", error);
}
});
});
});
</script>
</body>
</html>Normalde istek sonucunda böyle birşey görmem gerekiyor ama bunu kod olarak çalıştırınca böyle bir sonuç alamıyorum
yardımcı olabilir misiniz? ( özel bilgileri gizledim bu yüzden istek sonucu böyle kısa oldu) {"oauth":{"source":"google","accessToken":"ya29","expiresAt":1723312996,"properties":{"accountId":"750","partner":"snapfish","scope":"https://www.googleapis.com/auth/userinfo.profile openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/photoslibrary.readonly","givenName":"","idToken":"eNEdgISeT-8DjkOVuSFzmbp7BDKL9LEL1Ke-JvB5mJpnBv4mGdmTnF3Zw","name":" ","source":"google","userId":"1091","email":"@gmail.com","picture":""},"userId":"0113"}}