i am try to create a new project using resourcemanager.projects.create But got an error like :(
Google.Apis.Requests.RequestError
Request had insufficient authentication scopes. [403]
Errors [
Message[Request had insufficient authentication scopes.] Location[ - ] Reason[forbidden] Domain[global]
]
Can anyone please tell me What i am doing wrong. Here is my code :
private async void GoogleClick(object sender, RoutedEventArgs e)
{
try
{
var cr = new PromptCodeReceiver();
var result = await GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets { ClientId = GoogleClientId,ClientSecret = GoogleSecretKey },
new[] { "email", "profile" },
"user",
CancellationToken.None);
if (result.Token.IsExpired(SystemClock.Default))
{
await result.RefreshTokenAsync(CancellationToken.None);
}
CloudResourceManagerService cloudResourceManagerService = new CloudResourceManagerService(new BaseClientService.Initializer
{
HttpClientInitializer = GetCredential(result.Token.AccessToken, FirebaseAuthType.Google),
ApplicationName = "Kapiling",
//ApiKey = "apikey"
});
// TODO: Assign values to desired properties of `requestBody`:
Data.Project requestBody = new Data.Project();
requestBody.Name = "TESTING";
requestBody.ProjectNumber = 415104041262;
requestBody.ProjectId = "tokyo-rain-123";
requestBody.CreateTime = "2014-10-02T15:01:23.045123456Z";
ProjectsResource.CreateRequest request = cloudResourceManagerService.Projects.Create(requestBody);
}
I am try to access using public static GoogleCredential FromAccessToken(string accessToken, IAccessMethod accessMethod = null); method
public static GoogleCredential GetCredential(string accessToken, FirebaseAuthType authType)
{
GoogleCredential credential = GoogleCredential.FromAccessToken(accessToken, null);
return credential;
}
Thanks for everyone who help me i Solved this issues. Thanks again. :)
From looking at the GCP documentation, it seems like you (also) need the
https://www.googleapis.com/auth/cloud-platform
scope. See https://cloud.google.com/resource-manager/docs/authorizingChange your code for
GetCredential()
. Note: I am not sure what you are trying to do withFirebaseAuthType
so I have leftauthType
as an unused parameter.[EDIT]: Additional code to change due to the comment
createScopedRequired = false
You received this message because you already authenticated with scopes. To change the scopes requires another authorization. In this case request the correct scopes. Note, you do not need the other scopes (email and profile). Put them back in later if you do.