Created
June 19, 2016 16:44
-
-
Save ctrulove/73a49e009c0ffee4411a0a64cad12032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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