it did work, which somehow it really is a odd or strange behaviour, as i said in my first post, the code worked liked a charm until yesterday morning
the portal object should have (i guess) the CurrentUser set, a Token etc.... and instead those values are always null. If i make a POST request to generateToken to require a token, and set the portal instance Token property with the returned value, CurrentUser property is always null.
using System.Windows; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Portal; using Microsoft.Phone.Controls; namespace PhoneApp1 { public partial class MainPage : PhoneApplicationPage { public MainPage() { InitializeComponent(); IdentityManager.Current.TokenGenerationReferer = "file:///Applications/Install/"; IdentityManager.Current.GenerateCredentialAsync("http://www.arcgis.com/sharing/rest", "<username>", "<password>", (crd, err) => { if (crd != null) { var portal = new ArcGISPortal { Token = crd.Token }; portal.InitializeAsync(null, (p, e) => MessageBox.Show(p.CurrentUser.FullName)); } else MessageBox.Show("Error " + err.Message); }); } } }
If you are using using IE, that should work.For example, you can try to generate a token for the referer=http://<yourserver>
The problem was I changed "requestip" to my actual ip address.
My assumption is that token generated this way is bound to the ip and won't work if the map request is sent from a different IP?
Do you have any theory why the token generated using referer=MyToken won't work?
Yes:{"error":{"code":400,"message":"Unable to generate token.","details":["Invalid username or password."]}}
Strange! You got an error as if the option client=requestid was missing.Do you get that error when clicking on this link : https://www.arcgis.com/sharing/generateToken?f=json&username=myusername&password=mypassword&client=requestip
I did try what you suggested (space added so the full string can be shown):h t t ps://www.arcgis.com/sharing/generateToken?f=json&username=myusername&password=mypassword&client=requestipbut got an effor message:{"error":{"code":400,"message":"Unable to generate token.","details":["'referer' must be specified."]}}
Might be a problem due to the referer (I am not sure which referer you set in your token request).Instead of generating a token associated to a referer, you can try to generate a token associated to your ip address.Something like:https://www.arcgis.com/sharing/generateToken?f=json&username=myusername&password=mypassword&client=requestip
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.