iOSアプリをCordovaからReact-Nativeに移行しています。私はApp Engineのバックエンドを持っており、アプリでGoogleの認証を利用しています。コルドバでは、ユーザは単にWebViewのを使って自分のGoogleアカウントにログインします、これはクッキーをドロップするでしょうし、次のように彼らは、自分のデータにアクセスすることができます:Google認証後に認証クッキーが返されないネイティブネットワークリクエスト
function getSomeResource(callback_method)
{
$.ajax({
type: "GET",
url: 'https://myapp.appspot.com' + '/endpoint',
dataType: "jsonp",
cache: true,
xhrFields: {
withCredentials: true
},
success: function(result)
{
callback_method(result);
},
error: function(fail)
{
console.log(fail)
}
});
}
リアクトネイティブで、私はhttps://github.com/apptailor/react-native-google-signinプラグインを使用しています。次のように認証が動作します。
- ユーザーは
- ユーザーが自分のアプリケーション
とするときは、次の機能が
と呼ばれるにconst user = GoogleSignin.currentUser();
ユーザーオブジェクトはprovです片面。
しかし、質問がかどうかあり、以下のRNのネットワーク要求
fetch('https://myapp.appspot.com' + '/endpoint', {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Access-Control-Allow-Credentials' : 'true'
}
})
.then((response) => response.text())
.then((responseText) => {
var responseObject = JSON.parse(responseText);
console.log(responseObject);
});
を使用した場合、ログインしたとして何の認証クッキーがユーザーを認識しないのApp Engineバックエンドのため、後続の要求を格納していないようです(私たちがCordovaを使用したように)私がクッキーを取得する方法は何ですか?これを使用してGAEバックエンドに対してユーザーを認証できますか?