Unable to create a Team programmatically - c#

I have successfully created Office 365 Group, added members and owners and now I am trying to provision a Team for this group. How am I supposed to provision it using MS Graph in .NET Console App?
I tried the following code but I am not getting my Team.
var team = new Team
{
GuestSettings = new TeamGuestSettings
{
AllowCreateUpdateChannels = false,
AllowDeleteChannels = false
}
};
await graphServiceClient.Groups[groupID].Team.Request().CreateAsync(team);
Response from the above code
Message: No HTTP resource was found that matches the request URI 'https://api.teams.skype.com/v1.0/groups('da87fc59-403b-4b0f-973f-f812d41143aa')/team'.
Inner error
Error Screenshot
Edit: I am using latest NUGET package for MS Graph extensions.
Edit 2: Tried to do following instead.
await graphServiceClient.Groups[groupID].Team.Request().PutAsync(team);
Got this:
Code: UnauthorizedAccess
Message: Failed to execute Aad backend request GetTenantSubscribedSkusRequest. Request Url: https://graph.windows.net/dc7b2a82-XXXX-XXXX-XXXX-46122279d033/subscribedSkus?api-version=1.6, Request Method: GET, Response Status Code: Unauthorized, Response Headers: ocp-aad-diagnostics-server-name: HmmXXX+7Su9HNJVjwqsmVjPsrXXXXXXXX/iNwuI3H74=
request-id: 9257706c-XXXX-XXXX-XXXX-bbf33b98da7d
client-request-id: f263695b-XXXX-XXXX-XXXX-9fdf185fXXXX
Strict-Transport-Security: max-age=31536000; includeSubDomains
Date: Wed, 19 Jun 2019 13:20:18 GMT
Any suggestions?

Microsoft document says
If the group was created less than 15 minutes ago, it's possible for
the Create team call to fail with a 404 error code due to replication
delays. The recommended pattern is to retry the Create team call three
times, with a 10 second delay between calls.
I faced this issue and after the retry logic as suggested above it works fine all the time

Make sure you are using a Delegated authentication context (a user must be signed in) with the permission Group.ReadWrite.All
Make sure you have consented to the application permissions (from the API permissions screen of the application registration, you'll find a Grant Consent button all the way down)
Use the PutAsync method (today, as you mentioned, you must create the Office 365 group first and then enable Teams)

Can you confirm that the group actually gets created? "No HTTP resource was found that matches the request URI" often means that the graphServiceClient.Groups[groupID] doesn't work. Which is likely around permissions.

I noticed I have the same problem with application permissions. The one thing I have found that will unblock the code to work again is to create a team through the Graph Explorer and then I am good for a couple days.
Then the error comes back again and I create another team through the explorer and I can start creating like before. This tells me it is not a code problem but an issue on the Teams graph connection somewhere.

It was a service bug. Works now.
Link to service bug on GitHub

Related

New Server Security Causing Issues To API Response

one of my old project/app was working fine for years, very recently client report that app does not working any longer due to API response issue.
it's just a get request to an API with some parameters..
till date (before issues occurs) it returns following response:
,,3,1669179307,0,
but recently it shows following response: (note nothing is changed in the source php/code files since project start)
<html><title>You are being redirected...</title>
<noscript>Javascript is required. Please enable javascript before you are allowed to see this page.</noscript>
<script>var s={},u,c,U,r,i,l=0,a,e=eval,w=String.fromCharCode,sucuri_cloudproxy_js='',S='bT0nP2RUNCcuc3Vic3RyKDMsIDEpICsgJycgKyAKJz9iVGYnLnN1YnN0cigzLCAxKSArICcnICsgCidIcExjJy5zdWJzdHIoMywgMSkgK1N0cmluZy5mcm9tQ2hhckNvZGUoNTYpICsgJ3FAYycuY2hhckF0KDIpKyAnJyArIAonNycgKyAgICcnICsgClN0cmluZy5mcm9tQ2hhckNvZGUoMHg2MykgKyAgJycgKycnKyIyc3VjdXIiLmNoYXJBdCgwKSsiYyIgKyAiNHNlYyIuc3Vic3RyKDAsMSkgKyAiZW0iLmNoYXJBdCgwKSArICAnJyArIAoiM2MiLmNoYXJBdCgwKSArICIiICtTdHJpbmcuZnJvbUNoYXJDb2RlKDk3KSArICJlIi5zbGljZSgwLDEpICsgICcnICsnZCcgKyAgJ0RiJy5zbGljZSgxLDIpKyAnJyArJycrJ3hJMScuY2hhckF0KDIpK1N0cmluZy5mcm9tQ2hhckNvZGUoMHgzMSkgKyAncTAwJy5jaGFyQXQoMikrU3RyaW5nLmZyb21DaGFyQ29kZSgweDYzKSArICIiICsnSHVIZScuc3Vic3RyKDMsIDEpICsiN3N1Ii5zbGljZSgwLDEpICsgIjhzdSIuc2xpY2UoMCwxKSArICdjJyArICAiZHN1Y3VyIi5jaGFyQXQoMCkrJ2EnICsgICIiICsiY3N1Y3VyIi5j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script></html>
here is curl screenshot:
And here is the postman screenshot:
and when i check the URL in browser it shows the expected result, though when i check the devtool (network tab), it looks like page is loaded two times.. 1st one provide error (HTML/js) response (read marked) 2nd one provide the expected response (green marked), so, it looks like when it's called directly by curl/postman/c#... fails.. but as browser can do redirect it passed.
here is the browser screenshot:
i am sorry, i added several screenshot to give better idea what is happening.
and here is the URL in question:
https://simpleclienttracking.com/membershipmanager/remotelogvisit.php?locID=1&orgID=1&deptID=1&barcode=8346420
now my question, is how can i use the API code/file to get the direct response as i was getting earlier? do i need to pass any header? update/modify server htaccess file or what?
To test the error in deep, i have tried another URL from another hosting provider, in that case i am passing post request to an URL, and this server response slightly different thing, but looks like core is same, redirect!
here is the response from new/another server:
<script>document.cookie = "humans_21909=1"; document.location.reload(true)</script>
so, it's looks like hosting providers has applied some kind of security for direct URL access?
thanks in advance for any upcoming help
best regards

403 Message: Legacy People API has not been used in project [duplicate]

This question already has an answer here:
Legacy People API has not been used in project
(1 answer)
Closed 1 year ago.
Google API is active but give error ;
Legacy People API has not been used in project before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project= then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
You don't need to install any other APIs like Google Drive API, Google Sheets API or other except Google+ API,
The error is coming because of "passport-google-oauth": "^1.0.0"
Just change the version "passport-google-oauth": "^1.0.0" to "passport-google-oauth": "^2.0.0" and remove node_modules and package.lock.json file and run "npm i"
That's it
Before the Google+ API Shutdown on March 7, 2019, the people.get and people.getOpenIdConnect methods were available for requesting a person’s profile.
To avoid breaking existing integrations with these methods supporting sign-in, a new minimal implementation only returns basic fields necessary for that functionality, such as name and email address, if authorized by the user. The Legacy People API is where these methods will remain available for existing callers at the existing HTTP endpoints.
The Legacy People API serves a limited new implementation of the legacy Google+ API people.get and people.getOpenIdConnect methods necessary for maintaining sign-in functionality. It is available to existing callers of the original methods that haven't migrated to recommended replacements such as Google Sign-in or Google People API at the time of the Google+ API shutdown.
enter link description here
Thanks
In this case, I'm facing the same issue. This is what I've done to fix it.
Situation:
NodeJS ver 8
"passport-google-oauth": "^1.0.0"
Using Google+ API as Google Sign-in
When I run the apps and click Sign in with Google, what happened then?
Server error
Error log: Legacy People API has not been used in project "xxxx" before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=xxxx then retry.
How I solve it?
Go to Google Console
Click on Google+ API under Social APIs, then click Enable API
Click on Google Drive API under G Suite, then click Enable API
Click on Google Sheets API under G Suite, then click Enable API
Update "passport-google-oauth": "^1.0.0" to "passport-google-oauth": "^2.0.0"
in package.json
remove package-lock.json and node_modules folder (to ensure everything is clear)
run this command : npm install
It works now!
Note: my previous code still using profile._json.image.url to get profile image. Actually, this response was not there anymore. So I delete this code.
Goodbye Google+
Thank you Google People API.
Enabling the Google Contacts API and the Google+ API fixed this issue for me.
Hi I recently stumbeled on the same issue. As explained by Ilan Laloum, Google+ API as been decommissionned completely for new projects.
I found that Google People API works in a similar way. The following example is based on the Bookshelf tutorial in GCP. Source code can be seen here: https://github.com/GoogleCloudPlatform/golang-samples/tree/appengine/go111/cloudsql/getting-started/bookshelf (branch appengine/go111/cloudsql)
import people "google.golang.org/api/people/v1"
...
// retrieves the profile of the user associated with the provided OAuth token
func fetchProfile(ctx context.Context, tok *oauth2.Token) (*people.Person, error) {
peopleService, err := people.NewService(ctx, option.WithTokenSource(bookshelf.OAuthConfig.TokenSource(ctx, tok)))
if err != nil {
return nil, err
}
return peopleService.People.Get("people/me").
PersonFields("names,coverPhotos,emailAddresses").
Do()
}
This method needs a context and a OAuth token, just like Google+ API used to. The peopleService is initialized in a similar fashion.
The peopleService.People.Get("people/me") prepares a query that fetches the profile of the connected user. Then PersonFields("names,coverPhotos,emailAddresses") is a filter on profile fields. This part of the request is mandatory. Eventually Do() will execute the request.
This issue can be fixed using the passport-google-token
npm install passport-google-token
const GoogleStrategy = require('passport-google-token').Strategy;
// Google OAuth Strategy
passport.use('googleToken', new GoogleStrategy({
clientID: CLIENT_ID,
clientSecret: CLIENT_SECRET
}, async (accessToken, refreshToken, profile, done) => {
try {
console.log('creating a new user')
const newUser = new User({
google: {
id: profile.id,
email: profile.emails[0].value
}
});
await newUser.save();
done(null, newUser);
} catch (error) {
done(error, false, error.message);
}
}));
I was also having the same issue but with my Rails app. So I resolved it by upgrading the omniauth gems by running bundle update devise omniauth omniauth-google-oauth2 in terminal.
I also faced the same issue. This issue may occur for using the old library, enable the google people Api for your project, and download the library as per your php version from this link and integrate it.

Microsoft Graph Subscription ExtensionError - Delete / Update

Issue
I currently have an Azure Active Directory Application that has a Microsoft Graph Webhook Subscription listening for new emails (messages) in a specified mailbox.
The subscription has a scheduled task that renews the subscription's expiration date via an Update request. The subscription is targeted using its MS Graph Provided ID.
Any DELETE or UPDATE request against this specific subscription fails. (See 'Error Response' below.)
Question
I realize that this may be the same issue / bug as the question presented here: https://stackoverflow.com/a/53111286/7902641
Has there been any fix / resolution / or workaround for this?
If there has been a fix or this is a different problem altogether, what can I do to resolve this specific issue?
Thanks!
Error Response
{
"error": {
"code": "ExtensionError",
"message": "Operation: Delete; Exception: [Status Code: NotFound; Reason: The subscription with Id 'Q0IzOUZCMTYtMTk4OC00OEZDLUFFQjQtNzI4NTU1MDREMkVDXzQ5RDk2MzI3LUFDRDEtNEE2QS05QTQ1LUYwQ0ZGQjgwNEQ0Qg==' is not found.]",
"innerError": {
"request-id": "e83fe463-....-....-....-76eb35e2e697",
"date": "2019-03-22T02:35:14"
}
}
}
Extra Info
Somehow the Microsoft Graph ID for the subscription is...transformed? The original subscription ID is ( 528b79f1-....-....-....-360c0e1149e9 ) and the returned target ID is: ( Q0IzOUZ ... NEQ0Qg== ) .
The executing UPDATE request originates from an ASP.NET CORE application, using the Microsoft Graph SDK (C#).
https://github.com/microsoftgraph/msgraph-sdk-dotnet
However I have eliminated the SDK as the origination of the problem -- using a REST API tester (Insomnia), I achieve the same error result. The request URL looks like:
https://graph.microsoft.com/v1.0/subscriptions/528b79f1-....-....-....-360c0e1149e9
I have also attempted to use the BETA version instead of v1.0. Unfortunately I get the same error result.
Configuration
Application:
Registered Azure Active Directory Daemon Application
Authentication Library:
MSAL
https://github.com/AzureAD/microsoft-authentication-library-for-dotnet
Calling Application (generating the update / delete request):
ASP.NET CORE (2.1) - Web Api
Using MS Graph SDK (Github link posted above)
== Update ==
The subscription in question has now expired and disappeared from my application's subscriptions list (timestamp, PST: 3/22/2019 8:45:22 AM).
I will no longer be able to test against it (sorry S.O. posterity!).
However, good news: now that the problem child (subscription) in question is gone, I was able to create a new subscription and restart my affected service. I am able to successfully submit get / update / delete requests against any newly created subscriptions.
== Update ==
The subscription in question has now expired and disappeared from my application's subscriptions list (timestamp, PST: 3/22/2019 8:45:22
AM).
I will no longer be able to test against it (sorry S.O. posterity!).
However, good news: now that the problem child (subscription) in question is gone, I was able to create a new subscription and restart
my affected service. I am able to successfully submit get / update /
delete requests against any newly created subscriptions.
As this post is almost a year old and was most likely resolved via a fix by MSFT (no actionable fixes in our implementations), I am marking this post as "answered".
#baywet Thank you for the suggestion to do so.

HTTP 403 Server failed to authenticate the request when downloading Blob image from azure [duplicate]

I've search here and in Google but I can't find a solution.
With my C# code I want to read a file from Azure Storage Blob.
The code (only 6 line) works very well in another project (Windows 8.1 Universal App) but not in my new Windows 10 UWP App.
This is my code:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(azureConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("container-name");
CloudBlob b1 = container.GetBlobReference("27.76914.json");
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("stefano1.json", CreationCollisionOption.ReplaceExisting);
await b1.DownloadToFileAsync(file);
The Exception:
Server failed to authenticate the request. Make sure the value of
Authorization header is formed correctly including the signature.
Using Fiddler4 I found this error on message 403:
The MAC signature found in the HTTP request 'R2t9hKsyXf470HF2LNP8T+M2nci0ddE/ojQ0r4UVjJQ=' is not the same as any computed signature
My attempts:
The application works the first time (file downloaded). The second time I get the Exception.
If I change the requested file name: the application works the first time (file downloaded). The second time I get the Exception.
The next day I get immediately the same exception (at first run)
Also if I delete bin and obj folders I get the error
If I create another application and try to download the same file (same as point 1), it works the first time, but not the second.
In a Console Application all works well.
This is the Fiddler4 Raw Request (where ***** is my Azure Storage Account Name):
GET https://*****.blob.core.windows.net/container-name/27.76914.json HTTP/1.1
x-ms-client-request-id: accee7e7-646d-417a-b734-1591cbc16a8d
x-ms-date: Thu, 03 Sep 2015 06:31:37 GMT
x-ms-version: 2015-02-21
User-Agent: WA-Storage/5.0.2 (Windows Runtime)
Authorization: SharedKey *****:R2t9hKsyXf470HF2LNP8T+M2nci0ddE/ojQ0r4UVjJQ=
Host: *****.blob.core.windows.net
If-Modified-Since: Sun, 30 Aug 2015 18:52:41 GMT
If-None-Match: "0x8D2B16C2ED82C4A"
Connection: Keep-Alive
Thank you!
This was also reported on our GitHub page here: https://github.com/Azure/azure-storage-net/issues/171
Our leading theory is that a caching proxy might be in between the client and the server affecting your requests.
We're still investigating and will let you know.
I've had a similar issue (in Java) trying to access blobs from local machine.
Trying to download a blob would work one out of two times, trying to get an InputStream never worked. In both cases the error was the same as yours.
My code always worked from a VM in the cloud.
The issue was fixed when I've changed the default protocol from HTTP to HTTPS.
When constructing your CloudStorageAccount, there is a constructor that allows you to specify the default protocol. It's also available for C# (here)
Also for the record, AZCopy will fail for a source with HTTP, with similar error.
You might give it a try.

Azure Storage: 403 Server failed to authenticate the request

I've search here and in Google but I can't find a solution.
With my C# code I want to read a file from Azure Storage Blob.
The code (only 6 line) works very well in another project (Windows 8.1 Universal App) but not in my new Windows 10 UWP App.
This is my code:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(azureConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("container-name");
CloudBlob b1 = container.GetBlobReference("27.76914.json");
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("stefano1.json", CreationCollisionOption.ReplaceExisting);
await b1.DownloadToFileAsync(file);
The Exception:
Server failed to authenticate the request. Make sure the value of
Authorization header is formed correctly including the signature.
Using Fiddler4 I found this error on message 403:
The MAC signature found in the HTTP request 'R2t9hKsyXf470HF2LNP8T+M2nci0ddE/ojQ0r4UVjJQ=' is not the same as any computed signature
My attempts:
The application works the first time (file downloaded). The second time I get the Exception.
If I change the requested file name: the application works the first time (file downloaded). The second time I get the Exception.
The next day I get immediately the same exception (at first run)
Also if I delete bin and obj folders I get the error
If I create another application and try to download the same file (same as point 1), it works the first time, but not the second.
In a Console Application all works well.
This is the Fiddler4 Raw Request (where ***** is my Azure Storage Account Name):
GET https://*****.blob.core.windows.net/container-name/27.76914.json HTTP/1.1
x-ms-client-request-id: accee7e7-646d-417a-b734-1591cbc16a8d
x-ms-date: Thu, 03 Sep 2015 06:31:37 GMT
x-ms-version: 2015-02-21
User-Agent: WA-Storage/5.0.2 (Windows Runtime)
Authorization: SharedKey *****:R2t9hKsyXf470HF2LNP8T+M2nci0ddE/ojQ0r4UVjJQ=
Host: *****.blob.core.windows.net
If-Modified-Since: Sun, 30 Aug 2015 18:52:41 GMT
If-None-Match: "0x8D2B16C2ED82C4A"
Connection: Keep-Alive
Thank you!
This was also reported on our GitHub page here: https://github.com/Azure/azure-storage-net/issues/171
Our leading theory is that a caching proxy might be in between the client and the server affecting your requests.
We're still investigating and will let you know.
I've had a similar issue (in Java) trying to access blobs from local machine.
Trying to download a blob would work one out of two times, trying to get an InputStream never worked. In both cases the error was the same as yours.
My code always worked from a VM in the cloud.
The issue was fixed when I've changed the default protocol from HTTP to HTTPS.
When constructing your CloudStorageAccount, there is a constructor that allows you to specify the default protocol. It's also available for C# (here)
Also for the record, AZCopy will fail for a source with HTTP, with similar error.
You might give it a try.

Categories