Portal user info

View inQMLC++
View on GitHub
Sample viewer app

Retrieve a user's details via a Portal.

screenshot

Use case

This portal information can be used to provide a customized UI experience for the user. For example, you can show a thumbnail next to their username in the header of an application to indicate that they are currently logged in. Additionally, apps such as Collector and Explorer use this functionality to integrate with Portal.

How to use the sample

When prompted, enter your ArcGIS Online credentials.

How it works

  1. A Portal is created, and supplied a Credential which uses OAuth in user mode.
  2. When the app launches, the portal is loaded, which triggers an authentication challenge.
  3. An AuthenticationView listens to the challenge and displays a login screen to allow user credentials to be entered.
  4. If the portal is successfully loaded, the portalUser property is used to populate a series of fields including:

    • fullName
    • username
    • email
    • description
    • access
  5. Similarly, the portalInfo property is used to populate:

    • organizationName
    • organizationDescription
    • thumbnailUrl
    • canSearchPublic
    • canSharePublic

Relevant API

  • AuthenticationManager
  • AuthenticationView
  • Credential
  • PortalInfo
  • PortalUser

About the data

This sample signs into your ArcGIS online account and displays the user's profile information.

Tags

account, avatar, bio, cloud and portal, email, login, picture, profile, user, username

Sample Code

PortalUserInfo.qmlPortalUserInfo.cppPortalUserInfo.h
                                                                                                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// [WriteFile Name=PortalUserInfo, Category=CloudAndPortal]
// [Legal]
// Copyright 2016 Esri.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.Samples 1.0
import Esri.ArcGISRuntime.Toolkit 100.12

PortalUserInfoSample {
    id: rootRectangle
    clip: true
    width: 800
    height: 600

    readonly property var detailNames: ["Full name", "Username", "Email", "Bio", "Who can see your profile?"]
    readonly property var detailValue: ["fullName", "username", "email", "bio", "access"]
    readonly property var infoLabels: ["Description", "Can Find External Content", "Can Share Items Externally"]
    readonly property var infoValues: ["orgDescription", "canSearchPublic", "canSharePublic"]

    BusyIndicator {
        id: loadingIndicator
        anchors.centerIn: parent
        running: !loaded
    }

    Column {
        id: userDetailsColumn
        visible: loaded
        anchors {
            top: parent.top
            left: parent.left
            right: parent.right
            margins: 10
        }
        spacing: 10

        Text {
            text: fullName.length > 0 ? fullName + " Profile" : ("????")
            font.bold: true
            font.pointSize: 15
        }

        Image {
            source : thumbnailUrl.toString().length > 0 ? thumbnailUrl : "qrc:/Samples/CloudAndPortal/PortalUserInfo/placeholder_img.png"
            height: 32
            width: 32
        }
    }

    ListView {
        visible: loaded
        anchors {
            top: userDetailsColumn.bottom
            bottom: midLine.top
            left: parent.left
            right: parent.right
            margins: 10
        }
        spacing: 10
        clip: true
        model: detailNames.length

        delegate: Column {
            Text {
                text: detailNames[index]
                font.bold: true
            }

            Text {
                text: rootRectangle[detailValue[index]]
                color: "grey"
            }
        }
    }

    Rectangle {
        id: midLine
        anchors {
            verticalCenter: parent.verticalCenter
            margins: 8
            left: parent.left
            right: parent.right
        }
        height: 4
        visible: loaded
        color: "lightgrey"
    }

    Column {
        id: portalDetailsColumn
        visible: loaded
        anchors {
            top: midLine.bottom
            left: parent.left
            right: parent.right
            margins: 10
        }
        spacing: 10

        Text {
            text: orgTitle
            font.bold: true
            font.pointSize: 15
        }

        Image {
            source : orgThumbnailUrl
            height: 32
            width: 32
        }
    }


    ListView {
        id: infoList
        visible: loaded
        anchors {
            top: portalDetailsColumn.bottom
            bottom: parent.bottom
            left: parent.left
            right: parent.right
            margins: 10
        }
        spacing: 10
        clip: true
        model: infoValues.length

        delegate: Column {
            Text {
                text: loaded ? infoLabels[index] : ""
                font.bold: true
            }

            Text {
                text: rootRectangle[infoValues[index]]
                color: "grey"
            }
        }
    }

    /* Uncomment this section when running as standalone application
    AuthenticationView {
        id: authView
        anchors.fill: parent
    }
    */
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.