Код: Выделить всё
Error: Status(StatusCode=PermissionDenied, Detail="Request had insufficient authentication scopes.") ;
Код: Выделить всё
public async Task GetUserCredentialAsync(string user = null, GoogleOAuthState oAuthState = null)
{
using (ClientSecretStream)
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
if (oAuthState == null)
{
try
{
var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(ClientSecretStream).Secrets,
_Scopes,
string.IsNullOrEmpty(user) ? "user" : user,
CTS.Token,
new FileDataStore(credPath, true));
return new GoogleOAuthState(credential, _AppName);
}
catch (Exception e)
{
SetErrorMessage(e, "Error al intentar identificarse en google");
return null;
}
}
else
{
try
{
await GoogleWebAuthorizationBroker.ReauthorizeAsync(
oAuthState.Credential,
CTS.Token);
return oAuthState;
}
catch (Exception e)
{
SetErrorMessage(e, "Error al intentar volver a identificarse en google");
return null;
}
}
}
}
Код: Выделить всё
SheetsService.Scope.Spreadsheets
DriveService.Scope.DriveFile
DriveService.Scope.Drive
DriveService.Scope.DriveAppdata
DriveService.Scope.DriveMetadata
"https://www.googleapis.com/auth/datastore"
"https://www.googleapis.com/auth/cloud-platform"
Код: Выделить всё
GoogleOAuthStateПосле этого я подключаюсь к Firestore с помощью этого:
Код: Выделить всё
public async Task ConnectDB(GoogleLogin.GoogleOAuthState oAuthState)
{
var channelCredentials = oAuthState.Credential.ToChannelCredentials();
var channel = new Channel(FirestoreClient.DefaultEndpoint.ToString(), channelCredentials);
var client = FirestoreClient.Create(channel);
_DB = FirestoreDb.Create(Properties.Settings.Default.FirebaseProjectName, client);
}
Тем временем я установил такие правила пожарной безопасности:
Код: Выделить всё
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
Мне кажется, я что-то не понимаю... Возможно ли вообще это сделать? Или мне нужно использовать сервисную учетную запись?
Подробнее здесь: https://stackoverflow.com/questions/575 ... ion-scopes
Мобильная версия