Skip to content

Instantly share code, notes, and snippets.

@ctrulove
Created June 19, 2016 16:44
Show Gist options
  • Save ctrulove/73a49e009c0ffee4411a0a64cad12032 to your computer and use it in GitHub Desktop.
Save ctrulove/73a49e009c0ffee4411a0a64cad12032 to your computer and use it in GitHub Desktop.
function Get-InstagramAccessToken
{
param
(
$clientId,
$clientSecret,
$redirectUri
)
$accessCodeApiUri = "https://api.instagram.com/oauth/authorize/?client_id=$clientId&redirect_uri=$redirectUri&response_type=code"
start $accessCodeApiUri
$code = Read-Host -Prompt "Enter Code Query String Value"
$formData = @{
'client_id' = $clientId
'client_secret' = $clientSecret
'grant_type' = 'authorization_code'
'redirect_uri' = $redirectUri
'code' = $code
}
$uri = "https://api.instagram.com/oauth/access_token"
$response = Invoke-WebRequest -Uri $uri -Method Post -Body $formData -ContentType "application/x-www-form-urlencoded"
($response.Content | ConvertFrom-Json).access_token
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment