I am wondering whether any of you have a sample of creating a login for a Secured Feature Service in a Federated Server authenticated through portal? The examples provided are authenticating thru' arcgis.com and not giving an option for ArcGIS Enterprise. I a newbie- please ignore my starting trouble.
Thanks
Awesome- I could sign into portal. How can I pass that credential to a secured map service layer?
Here is the reference -- https://developers.arcgis.com/javascript/3/jssamples/portal_oauth_inline.html
Thank you very much! Yes, I looked into Oauth jsapi one- confused with how to get it to work in Enterprise. I am sorry, I should have mentioned how I was trying to achieve it. I am trying to put together a basic web app- through javascript. The python example is great- by any chance- do you have a javascript example?
For the Oath piece, have you looked the documentation? https://developers.arcgis.com/documentation/mapping-apis-and-services/security/oauth-2.0/
Oh!!! The URL for the portal token you may need is here: https://yourserver.com/webadaptorname/admin/login
I am assuming you are going to use the Portal server in that URL and portal web adaptor name.
I am assuming you are doing this outside of Pro, Desktop or a Web Application Builder type app and directly inserting via API.
Python example:
def get_token():#-------------------------------------------------------------------------------# Name: Function -# Purpose:#-------------------------------------------------------------------------------data = checklist.b64decode(AGOL_Pass)pw = data.decode("ascii")url = 'https://www.arcgis.com/sharing/rest/generateToken'values = {'f': 'json','username': AGOL_User,'password': pw,'referer' : 'https://www.arcgis.com','expiration' : '10'}data = urllib.parse.urlencode(values).encode("utf-8")req = urllib.request.Request(url)response = Nonewhile response is None:try:response = urllib.request.urlopen(req,data=data)except:passthe_page = response.read()#Garbage Collection with some house buildingpayload_json = the_page.decode('utf8')payload_json = json.loads(payload_json)edit_token = payload_json['token']return (edit_token)
def get_token():#-------------------------------------------------------------------------------# Name: Function -# Purpose:#-------------------------------------------------------------------------------
data = checklist.b64decode(AGOL_Pass)pw = data.decode("ascii")
url = 'https://www.arcgis.com/sharing/rest/generateToken'values = {'f': 'json','username': AGOL_User,'password': pw,'referer' : 'https://www.arcgis.com','expiration' : '10'}
data = urllib.parse.urlencode(values).encode("utf-8")req = urllib.request.Request(url)
response = Nonewhile response is None:try:response = urllib.request.urlopen(req,data=data)except:pass
the_page = response.read()
#Garbage Collection with some house buildingpayload_json = the_page.decode('utf8')payload_json = json.loads(payload_json)
edit_token = payload_json['token']
return (edit_token)
If you are trying to do this through a web app as an example though, you can take the route of getting a long term token. In this case though, there are some perils involved depending on how you configure things. You would tack on ?token={}, {} being the token you would insert for the service. This would allow you to use a Portal account as authentication for that feature service.
What I am trying to accomplish is - edit a secured Feature table published as a featureservice in a federated server. Normally when you load a secured featureservice, it will prompt for user credentials.
So, what I am trying to do is authenticate it first and then pass the credentials to that feature service (remember the session) and perform add/edit/update etc on that feature table.
The Oauth2 example shows how to authenticate through ArcGIS.com which doesn't give an option to switch the login to ArcGIS enterprise. If you have an example to accomplish this- that would be great. I though this is a common scenario which everybody come across to do a basic CRUD operation against a feature layer/table. But, stuck on where to start 😞 without a sample. Also, please suggest some learning recommendations too. Thanks!
Are you just trying to lift the data through the API or are you trying to make it so a user does not have to log into a secured service when using a map product?
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.