有兩種方法可以使用分配給用戶的列表應用程序。首先是需要具有正確特權的API令牌的服務器端調用。其次是用戶與Okta進行活動會話後的瀏覽器調用。您需要用戶名才能進行第二次通話。
GET /api/v1/apps?filter=user.id+eq+"{{userId}}"
- >從服務器端的
GET /api/v1/users/{{username}}/appLinks
- >從瀏覽器/ JavaScript的
爲了測試第二個呼叫,則URL粘貼到與已登錄一個瀏覽器在會話中確保您獲得理想的結果。如果進行AJAX調用,您需要在xhrFields
中發送withCredentials: true
。例如:
$.ajax({
type: "GET",
url: "https://example.okta.com/api/v1/users/{{username}}/appLink",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
xhrFields: {
withCredentials: true
},
cache: false,
success: function(data, status)
{
},
error: function(data, status)
{
}
});
這兩個調用都會返回分配給用戶的應用程序。
1:您可以包含GET請求的示例,列出應用程序分配給用戶? http://developer.okta.com/docs/api/resources/apps.html#list-applications-assigned-to-user 2:您是否也可以包含您獲得的請求和結果的清理示例? –
1. {{url}}/api/v1/apps?filter = user.id + eq +「{{userId}}」 2.https://jsfiddle.net/#&togetherjs=zLIyUg25um –