2016-04-14 5 views
2

私はこれを達成するためにPowerShellとOneDrive APIを使用しています。私はすべてのフォルダ/ファイル/ etcを得ることができますが、特定のファイルが共有されているすべてのユーザーをどこにリストすることができるかを見つけるのは苦労しています。私のスコープはすでにwl.skydrive_contactsを含んでおり、私はすでにAPIを使っている全てのフォルダ/ファイルのリストを持っています。誰か私にいくつかの洞察力を与えることができる?外部ユーザーと共有されたOnedrive APIリストファイル

+0

でサンプルを見ることができますか?あなたのコードとあなたがそれを実行するときに得るエラーを共有できますか? – TheMadTechnician

+0

私はドライブのルートを取得するためにこれを使用しています、そして、異なるフォルダIDを呼び出すことによってフォルダ/ファイルを選ぶことができます。私が困惑している部分は、これらの共有ファイルのアクセス権を取得しています。これを実行すると、$ _。shared_withがAccess = Sharedを示していることがわかります。 $ Root = Invoke-RestMethod -Uri "$ ApiUri/me/skydrive?access_token = $ AccessToken" – jheinikel

+0

また、invoke-restmethod -Method GET -URI "$ APIURI/$ FileID/Permissions"を実行したときに発生するエラー? access_token = $ accesstokenはURLに無効なパスPermissionsが含まれていることです。 – jheinikel

答えて

1

OneDrive Rest APIを使用すると、すべての共有アイテムを一覧表示できます。その前に

、あなたは、あなたは以下のコードを使用することができますhttps://dev.onedrive.com/app-registration.htm

に応じて自分のOneDriveへの適切なアクセスを得るためにアプリケーションを登録する必要があります。完全な手順については

$ClientId = "<Your application client id>" # your application clientid 
$SecrectKey = "<Your application key>" # the secrect key for your application 
$RedirectURI = "<Your web app redirect url>" # the re-direct url of your application 

Function List-SharedItem 
{ 
    [CmdletBinding()] 
    Param 
    ( 
     [Parameter(Mandatory=$true)][String]$ClientId, 
     [Parameter(Mandatory=$true)][String]$SecrectKey, 
     [Parameter(Mandatory=$true)][String]$RedirectURI 
    ) 

    # import the utils module 
    Import-Module ".\OneDriveAuthentication.psm1" 

    # get token 
    $Token = New-AccessTokenAndRefreshToken -ClientId $ClientId -RedirectURI $RedirectURI -SecrectKey $SecrectKey 

    # you can store the token somewhere for the later usage, however the token will expired 
    # if the token is expired, please call Update-AccessTokenAndRefreshToken to update token 
    # e.g. 
    # $RefreshedToken = Update-AccessTokenAndRefreshToken -ClientId $ClientId -RedirectURI $RedirectURI -RefreshToken $Token.RefreshToken -SecrectKey $SecrectKey 

    # construct authentication header 
    $Header = Get-AuthenticateHeader -AccessToken $Token.AccessToken 

    # api root 
    $ApiRootUrl = "https://api.onedrive.com/v1.0" 

    # call api 
    $Response = Invoke-RestMethod -Headers $Header -Method GET -Uri "$ApiRootUrl/drive/shared" 

    RETURN $Response.value 
} 

# call method to do job 
$Results = List-SharedItem -ClientId $ClientId -SecrectKey $SecrectKey -RedirectURI $RedirectURI 

# print results 
$Results | ForEach-Object { 
    Write-Host "ID: $($_.id)" 
    Write-Host "Name: $($_.name)" 
    Write-Host "ParentReference: $($_.parentReference)" 
    Write-Host "Size: $($_.size)" 
    Write-Host "WebURL: $($_.webUrl)" 
    Write-Host 
} 

、あなたは何を試してみましたhttps://gallery.technet.microsoft.com/How-to-use-OneDrive-Rest-5b31cf78

関連する問題