-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Graph] Fix code samples in README #4754
Conversation
Fix code samples - use tenantId vs subscriptionId
Remove extraneous curly brackets
Add domain (tenantId) to interactiveLogin call
@@ -68,7 +71,7 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to | |||
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script> | |||
<script src="node_modules/@azure/graph/dist/graph.js"></script> | |||
<script type="text/javascript"> | |||
const subscriptionId = "<Subscription_Id>"; | |||
const tenantId = "<Tenant_Id>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this tenantId
different from the one in line 33?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ramya-rao-a - they are part of separate code examples. The tenantId on line 74 is part of the browser-specific example, whereas the one on line 33 you mentioned is part of the Node.js example. In practice, they should never be used together so there wouldn't actually be redundant variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thats right. Apologies, that was an oversight from my end :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I would suggest to update line 33 to const tenantId = "<Tenant_Id>";
as well because we dont talk about the environment variable DOMAIN needing to be set anywhere in the readme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that makes sense. I was trying to change the original code as little as possible and it referenced an env var for subscription id prior to my other updates.
There's some additional code that can be removed (the following imports on lines 29-30 aren't used and aren't necessary for the example to run, I have tested this):
import * as msRest from "@azure/ms-rest-js";
import * as msRestAzure from "@azure/ms-rest-azure-js";
I have added a couple commits with the above changes.
Thanks for getting started on this @mikesprague! |
Remove unused imports
Update tenantId for consistency across browser/Node examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good.
Before I merge, can you share some pointers to the docs that talk about tenant id for Azure Graph?
The source code for the current SDK (
Also, here are the examples from the "old" SDK ( FWIW, I spent more time then I'd like to admit trying to get the examples (as currently listed on the README) to work using the subscription id. While that wasn't the only issue, I have gone back and compared using subscription id to tenant id and subscription id fails/errors out every time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the time you have spent on this @mikesprague!
This library has been auto-generated and so have the samples in the README file.
We are looking at improving this process, but this has been a great first step towards that.
Thanks again!
Code samples for the Graph client do not work as written. This PR updates the samples with the necessary changes for them to run.
tenantId
vssubscriptionId
in Node and browser code examplesdomain
tointeractiveLogin
call in Node example