Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting presence data from the Microsoft Graph API #175

Closed
jonathanwelton opened this issue Jan 8, 2021 · 5 comments
Closed

Getting presence data from the Microsoft Graph API #175

jonathanwelton opened this issue Jan 8, 2021 · 5 comments
Assignees

Comments

@jonathanwelton
Copy link

I am trying to use the sample app to request presence data from the Microsoft Graph API.

From what I can tell, everything is configured correctly, but I am getting the following error when it tries to create the subscription:
Error: Operation: Create; Exception: [Status Code: Forbidden; Reason: The request is not authorized for this user or application.]

As I understand it, you can only request presence data using a certificate. I tried using a client secret previously without any success.

I have set includeResourceData to true in the subscription configuration so the certificate and private key is generated for me using OpenSSL.

My subscription configuration is as follows:

exports.subscriptionConfiguration = { changeType: 'updated', notificationUrl: 'https://123456789.ngrok.io/listen', resource: '/communications/presences/[my user GUID]', clientState: 'SecretClientState', includeResourceData: true };

In my Azure app I have added delegated permissions for Presence.Read (and the same for Presence.Read.All and User.Read, just in case).

I also uploaded the certificate in the 'Certificates & secrets' section, but I don't know if that's necessary, or if there's other configuration I need to do.

Thanks for any help!

@Jumaodhiss
Copy link

@jonathanwelton hi, Kindly share your Client Request Id and the UTC time stamp so that we can help you troubleshoot.

Thanks
George

@jonathanwelton
Copy link
Author

@Jumaodhiss Can you tell me where can I find those values?

@Ajaldin
Copy link

Ajaldin commented Mar 16, 2021

The documentation to get this data is not mentioning anything about certificates, so you should be able to use the sample as is and get the data.
https://docs.microsoft.com/en-us/graph/api/presence-get?view=graph-rest-1.0&tabs=http
Try Graph explorer to see if you can get the data with the methods mentioned in the documentation, if that's successful so you don't really need additional certificates.

@jasonjoh
Copy link
Member

Attempting to get this back on track.

@Jumaodhiss Can you tell me where can I find those values?

Those values are returned in the error response as part of the body in the HTTP payload. You should be able to get this by wrapping your API call in a try/catch. Something like:

try {
  const subscription = await client.api(this.subscriptionPath).version('beta').create(subscriptionCreationInformation);
} catch (err) {
  console.log(JSON.stringify(err, Object.getOwnPropertyNames(err)));
}

It would also be good to console.log your access token, then parse it with https://jwt.ms and see exactly what scopes you have in the token.

@ghost
Copy link

ghost commented Sep 2, 2021

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost ghost closed this as completed Sep 7, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants