FirebaseとAngular 2を使用して、ユーザーを自分のアプリケーションに検証し、ユーザーのYouTubeチャンネル情報を取得しようとします。 。電子メールのスコープを削除し、Firebaseを使用してyoutube.readonlyスコープを追加する方法GoogleAuthProvider
return new Promise((resolve, reject) => {
let provider = new firebase.auth.GoogleAuthProvider();
let token: any;
let fullData: any;
provider.addScope('https://www.googleapis.com/auth/youtube.readonly');
firebase.auth().signInWithPopup(provider).then(result => {
token = result.credential.accessToken;
fullData = {
uid: (result.user.uid || ""),
photoURL: (result.user.photoURL || ""),
name: (result.user.displayName || ""),
youtube_channel: {}
}
let headers = new Headers();
let googleAPI = "https://www.googleapis.com/youtube/v3/channels?part=brandingSettings%2C+snippet%2C+id%2C+statistics&mine=true";
headers.append('Authorization', 'Bearer ' + token);
headers.append('Content-Type', 'application/json');
return this.http.get(googleAPI, { headers })
.map(res => res.json())
.subscribe(data => {
fullData.youtube_channel = data;
return this.userProfile.child(fullData.uid).update(fullData).then(_ => {
resolve(fullData);
});
})
}).catch(err => {
console.error(err);
resolve();
})
});
問題は、このコードを実行すると、それが動作し、私は必要な情報を取得して、ユーザがログインするが、Googleはメール、プロファイルのユーザーに尋ねると、YouTubeが読み取り権限をされています。ここに私のコードです。私はプロファイルとYouTubeの読み取り許可を必要としますが電子メールは必要ありません - 私はOauthウィンドウのポップアップをGoogleがユーザーの電子メールを尋ねることは望ましくありません。
Firebaseには、provider.addScope( '...')しかありませんが、電子メールのスコープは削除できますか(これは私が推測するデフォルトのスコープですか?)。 Firebaseの専門家、助けてください!
これはあまりにも複雑で、私の頭の上に行きました...私は自分のGoogleシングルサインインを展開するのではなく、私のためにいくつかのネイティブFirebaseソリューションを探しています。それはまったく...別の方法はありませんか? –