-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Using the Access Token #1374
Comments
Please take a look at the examples and the tutorial. You should be able to find your answer. Documentation: |
I cant find the answer :( I have the following code: Add-PodeWebPage -Name 'Subscriptions' -Icon 'Settings' -ArgumentList $accesstoken -ScriptBlock {
param($Accesstoken)
New-PodeWebCard -Content @(
New-PodeWebTable -Name 'Subscriptions' -ArgumentList $accesstoken -ScriptBlock {
param($Accesstoken)
$config = Get-PodeConfig
$tenantid = $config.tenantId
$Uri = "https://login.microsoftonline.com/$tenantid/oauth2/v2.0/token"
$Headers = @{'Content-Type' = 'application/x-www-form-urlencoded' }
$Method = 'POST'
$Body = @{
grant_type = 'urn:ietf:params:oauth:grant-type:jwt-bearer'
scope = 'https://management.azure.com/.default'
client_id = $config.clientId
client_secret = $config.clientSecret
assertion = $accessToken
requested_token_use = 'on_behalf_of'
}
$token = (Invoke-WebRequest -Uri $Uri -Method $Method -Headers $Headers -Body $body).Content | ConvertFrom-Json -Depth 10
$uri = "https://management.azure.com/subscriptions?api-version=2022-12-01"
# Set up the headers, including the authorization token
$headers = @{
"Authorization" = "Bearer $($token.access_token)"
"Content-Type" = "application/json"
}
(Invoke-RestMethod -Uri $uri -Method Get -Headers $headers).value | Select-Object DisplayName, SubscriptionId, State
}
)
} I am looking for a way to not have access tokens as parameters. I guess I could save them as secret, but it is only for a session. |
This is a Pode.Web question. You posted on the wrong forum. |
Hey @Dylan-Prins, It looks like you're using OAuth with AAD? There's a write-up of it here: https://badgerati.github.io/Pode/Tutorials/Authentication/Inbuilt/AzureAD/#full-example The Hope that helps :) |
Question
I want to use the access token generated from Add-PodeAuth in other WebPAges.
I cant find how to do this
The text was updated successfully, but these errors were encountered: