-
Notifications
You must be signed in to change notification settings - Fork 29
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
Connect to REST API using OAuth2 #45
Comments
Thank you for the kind words, @daniel-alsen! Since the sample you mentioned refers to an anonymous API, I suggest that we keep it as-is and instead work on creating a new sample. Is this something that you'd like to work on or are you rather looking for an example of how to solve it? |
I'm new with PowerShell and GraphConnectors, so I'm looking for a sample in this case. But happy to contribute with other samples in the future when I get my arms around this :) |
@nanddeepn, @SmitaNachan, see the question from @daniel-alsen above. Have you by any chance worked on creating a Graph connector in PowerShell, that's connected to an API behind OAuth? If so, would you be willing to share it? If not, is this something that perhaps you'd like to work together on to share with others? 😊 |
I haven't written anything in PowerShell, but I wrote the following code with help from ChatGPT, and it works. Feel free to use it in the commentary of the sample if you want. $authURL = "https://xxx/oauth/token"; $creds = @{ $authHeader = @{"content-type" = "application/x-www-form-urlencoded"} $response = Invoke-RestMethod "$authURL" -Method Post -Body $creds -Headers $authHeader $token = $response.access_token; $apiUrl = "https://xxx"; $json = Invoke-RestMethod -Uri "$apiUrl" -Method Get -ContentType "application/json" -Header $authHeader |
Hi @daniel-alsen |
Thank you Nanddeep! |
Considering completed due to lack of further comments |
Thank you for creating this useful sample library!
I used the REST Countries sample with Powershell as basis for a Graph Connector used for Copilot. Would it be possible to complement that sample with a few lines of code describing how to connect via PowerShell if the REST API uses OAuth2 with a token?
Best regards,
Daniel
The text was updated successfully, but these errors were encountered: