|
POST
|
Hi, I am trying to get a token using OAuth2 from a web app. I am able to do it using the /authorize endpoint if using response_type=token. However, this returns the token in plan text in the redirect url which I find a bit low security. I guess it is in the user's own browser, so perhaps not that big a deal. I thought I would try to use the approach of getting an authorization code and then use the /token endpoint to get the token. However, I am unable to retrieve this successfully. Initially I send the /authorize request string authorizeUrl = "https://www.arcgis.com/sharing/rest/oauth2/authorize";
string clientId = "my-client-id";
string redirectUrl = "https://localhost:7109/counter";
string responseType = "code";
string codeChallenge = "12345";
string codeChallengeMethod = "plain";
Console.WriteLine($"Index Challenge: {codeChallenge}");
$"{authorizeUrl}?client_id={clientId}&redirect_uri={redirectUrl}&response_type={responseType}&code_challenge={codeChallenge}&code_challenge_method={codeChallengeMethod}";
UriBuilder builder = new UriBuilder(authorizeUrl)
{
Query = $"client_id={clientId}&redirect_uri={redirectUrl}&response_type={responseType}&code_challenge={codeChallenge}&code_challenge_method={codeChallengeMethod}"
};
string oAuthUrl = builder.ToString();
NavigationManager.NavigateTo(oAuthUrl); This works perfect and takes me to the login page and when I login I am then redirected correctly to redirect page and the code is attached. So then a post request is made to get the /token endpoint //this gets the returned code, I have validated that it matches when is in the redirect Url
string code = Navigation.Uri.Substring(Navigation.Uri.IndexOf("=", StringComparison.Ordinal) + 1);
string tokenUrl = "https://www.arcgis.com/sharing/rest/oauth2/token";
string clientId = "my-client-id";
string redirectUrl = "https://localhost:7109/counter";
//string codeChallenge = CreateSHA256Challenge();
string codeChallenge = "12345";
var dictionary = new Dictionary<string, string>
{
{"client_id", clientId},
{"grant_type", "authorization_code"},
{"code", code!},
{"code_verifier", codeChallenge},
{"redirect_uri", redirectUrl}
};
FormUrlEncodedContent content = new FormUrlEncodedContent(dictionary);
using HttpClient client = new HttpClient();
var response = await client.PostAsync(tokenUrl, content);
var json = await response.Content.ReadAsStringAsync(); However, this fails and returns {
"error": {
"code": 400,
"error": "invalid_request",
"error_description": "Invalid PKCE code_challenge_verifier",
"message": "Invalid PKCE code_challenge_verifier",
"details": []
}
} The example I am just using a very simple challenge in plain text to make this as easy as possible to validate. Is there something I am missing in the /token request? One thing I find odd is you do not need to specify if is plain or S256 in the /token request. The /token post call is within milliseconds of the initial /authorize request so nothing could have expired. Does anyone has thoughts on what I am missing? Thanks - Joe
... View more
07-29-2022
02:46 PM
|
0
|
4
|
13822
|
|
POST
|
Hi, I am wondering if anyone has tried (successfully) to setup OAuth in a Blazor Web Assembly. I think I have things configured based on the documentation but continue to get an error saying it is not setup correct. Without any specifics. Thanks - joe
... View more
07-28-2022
10:28 AM
|
0
|
3
|
2310
|
|
POST
|
Hi, Am seeing some really odd behavior with Windows and authentication. I have code that works fine in Xamarin forms on iOS. Very simple, just setting up Authentication. What I am seeing though is that in WPF (both Win standard and NET6) the challenge handler does not get called. It just does not go into the method, and then I get an unauthorized error trying to open the item. As I said, the same code works in Xamarin Forms, I can look at the AuthenticationManager and see a registered method for the challenge handler, but it does not enter the method. Any thoughts on something additional needed in WPF. I have gone through the samples and do not see anything being done that differs Thanks - Joe
... View more
07-25-2022
09:31 AM
|
0
|
6
|
3265
|
|
POST
|
See this thread Code to use MAUI (until official support in ArcGIS Runtime for .NET) which @SomeGISGuy has been commenting on. Seems they are doing their best to keep up with a moving target. Other XF APIs I am working with seem to be having similar struggles moving to MAUI
... View more
07-18-2022
09:02 AM
|
0
|
0
|
1449
|
|
POST
|
Hi Morten, Wondering if anything in the latest updates might impact iOS showing a MapView. I'm at Visual Studio Version 17.3.0 Preview 3.0 and Runtime 100.14.1-preview3. I get a map to show up in Windows but not in iOS 15.5 simulator. Thanks -Joe
... View more
07-15-2022
08:03 AM
|
0
|
1
|
3258
|
|
POST
|
Not sure I understand the return false; inside the conditional, because it will only remove the first one it finds that meets this condition. I would use LINQ to get a IEnumerable of the graphics I want to remove and then loop through it to do the removals. Again not clear on the purpose of the return, but the below example would return false if anything needed to be removed var graphics = _graphicsOverlay.Graphics.Where(g =>
(int)g.Attributes["ORDER"] == mapUnits.Order && (int)g.Attributes["RANGE"] == range &&
g.Attributes["TYPE"].ToString() == "RING");
bool result = true;
foreach (var graphic in graphics)
{
_graphicsOverlay.Graphics.Remove(graphic);
result = false;
}
return result; You are going to get an illegal cast exception if either ORDER or RANGE is null. You could do something along these lines to avoid that possibility var graphics = _graphicsOverlay.Graphics.Where(g =>
{
int order = g.Attributes["ORDER"] == null ? 0 : (int)g.Attributes["ORDER"];
int range = g.Attributes["RANGE"] == null ? 0 : (int)g.Attributes["RANGE"];
string type = g.Attributes["TYPE"] == null ? string.Empty : g.Attributes["TYPE"].ToString();
return order == mapUnits.Order && range == _range && type == "RING";
});
bool result = true;
foreach (var graphic in graphics)
{
result = false;
_graphicsOverlay.Graphics.Remove(graphic);
}
return result;
... View more
07-08-2022
09:26 AM
|
0
|
2
|
1504
|
|
POST
|
It seems to me you would need a custom LocationDataSource. This is not overly complex to implement. You would need to read the file and then call the UpdateLocation with the Location object you create from the data stream you are receiving. Then on the MapView you update the LocationDisplay.DataSource to use your custom LocationDataSource. After that everything would behave as though you were receiving location from any other data source.
... View more
06-14-2022
10:53 AM
|
1
|
0
|
1511
|
|
POST
|
Here is what is in the AppCenter Diagnostics: Application.Main (System.String[] args) /Users/runner/work/1/s/src/Mobile.Design.iOS/Main.cs, line 15 SIGABRT: Could not initialize an instance of the type 'ExternalAccessory.EASession': the native 'initWithAccessory:forProtocol:' method returned nil. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false Line 15 is just the startup: UIApplication.Main(args, null, typeof(AppDelegate)); --------------------------- Stack traces NSObject.InitializeHandle (System.IntPtr handle, System.String initSelector) /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSObject2.cs:609 /Users/builder/azdo/_work/2/s/xamarin-macios/src/build/ios/native/ExternalAccessory/EASession.g.cs:79 Esri.ArcGISRuntime.Location.NmeaLocationDataSource+EAAccessoryStream..ctor (ExternalAccessory.EAAccessory accessory, System.String protocol) [0x0000d] in <fc2ff9f8183b4871b39c22ae8fb2d60c>:0 NmeaLocationDataSource+<>c__DisplayClass33_0.<FromAccessory>b__0 (Esri.ArcGISRuntime.Location.NmeaLocationDataSource d) NmeaLocationDataSource+CreateStreamNmeaLocationDataSource.OnStartAsync () ArcGISException.HandleCoreError (RuntimeCoreNet.GeneratedWrappers.CoreError error, System.Boolean throwException) Interop.CheckError (System.IntPtr errorHandle, System.Boolean throwOnFailure, System.Runtime.InteropServices.GCHandle wrapperHandle) CoreTask.Get () CoreTaskExtensions+TaskCompletedCallbackHandler.OnCompleted (System.Object sender, System.EventArgs e) CoreTaskExtensions+TaskCompletedCallbackHandler.CreateInternal (RuntimeCoreNet.GeneratedWrappers.CoreTask task, System.Threading.CancellationToken cancellationToken) MapViewControl.SetupLocationDataSource () AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 NSAsyncSynchronizationContextDispatcher.Apply () /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSAction.cs:178 (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) /Users/builder/azdo/_work/2/s/xamarin-macios/src/UIKit/UIApplication.cs:85 Application.Main (System.String[] args) /Users/runner/work/1/s/src/Mobile.Design.iOS/Main.cs:15 Looking at it I do see a place that I could catch an exception I had not noticed before. But one thing that really confuses me is the user reporting that this has occurred once they have connected and have collected a point. The initialization of the LocationDataSource is done when the MapView is initially loaded. So I am not clear how there would be an additional attempt to connect (and there is always the chance the user who reported things is describing something incorrectly). It is not an issue that occurs often, it may have only happened on one day. The device is a Geneq SxBlue. We have 100 users with the exact same device in the field Thanks
... View more
06-01-2022
10:08 AM
|
0
|
1
|
1253
|
|
POST
|
Hi, [lets try and write this a second time after GeoNet failed] We switched over to the NmeaLocationDataSource from our own custom LocationDataSource for collecting from an external iOS device. Been working great and removed a lot of custom code But we have gotten a system crash when using the NmeaLocationDataSource. It has happened both when making initial connection to the unit and once the user is already collecting GPS data. When it happens while collecting data the user does say they see the LastKnown location indicator (the grey dot). The stack trace shows occurring in OnStartAsync. So not sure if it tries to call this again when the connection is dropped. It seems to me to be an issue with the actual connection between the unit and the iOS device, but possibly is a result of the unit not receiving good data As much as anything it would be nice to be able to catch the exception so it does not crash the application but I cannot seem to find where one would handle the exception Thanks @SomeGISGuy Stack trace from crash NSObject.InitializeHandle (System.IntPtr handle, System.String initSelector) /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSObject2.cs:609
/Users/builder/azdo/_work/2/s/xamarin-macios/src/build/ios/native/ExternalAccessory/EASession.g.cs:79
Esri.ArcGISRuntime.Location.NmeaLocationDataSource+EAAccessoryStream..ctor (ExternalAccessory.EAAccessory accessory, System.String protocol) [0x0000d] in <fc2ff9f8183b4871b39c22ae8fb2d60c>:0
NmeaLocationDataSource+<>c__DisplayClass33_0.<FromAccessory>b__0 (Esri.ArcGISRuntime.Location.NmeaLocationDataSource d)
NmeaLocationDataSource+CreateStreamNmeaLocationDataSource.OnStartAsync ()
ArcGISException.HandleCoreError (RuntimeCoreNet.GeneratedWrappers.CoreError error, System.Boolean throwException)
... View more
05-31-2022
10:46 AM
|
0
|
3
|
1279
|
|
POST
|
Thanks for this, saved us on a Friday night upgrade
... View more
05-24-2022
11:56 AM
|
0
|
0
|
2580
|
|
POST
|
I know how to update a domain associated at the feature level in AGOL. However, in many cases domains have to be applied at the subtype level (Utility Network standard is setup in this manner). Is there a way to do this to an already published feature service. I know the UI won't support, but what about via rest or python API Thanks
... View more
05-11-2022
07:20 AM
|
0
|
0
|
487
|
|
POST
|
For internet/cell connectivity I use the Xamarin.Essentials library Connectivity object Connectivity.ConnectivityChanged += OnConnectivityChanged;
... View more
04-05-2022
10:39 AM
|
1
|
0
|
2254
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-11-2026 09:07 AM | |
| 1 | 10-23-2025 12:16 PM | |
| 1 | 10-19-2022 01:08 PM | |
| 1 | 09-03-2025 09:25 AM | |
| 1 | 04-16-2025 12:37 PM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|