-
Notifications
You must be signed in to change notification settings - Fork 288
App Center Integration #234
base: master
Are you sure you want to change the base?
Changes from 1 commit
70e717b
e3b3f9d
7bfdaa0
a8eae3e
858b069
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<ContentDialog | ||
x:Class="HoloLensCommander.SetAPItokenDialog" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:HoloLensCommander" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Title="Set API Token" | ||
PrimaryButtonText="Ok" | ||
SecondaryButtonText="Cancel" | ||
PrimaryButtonClick="ContentDialog_PrimaryButtonClick" | ||
SecondaryButtonClick="ContentDialog_SecondaryButtonClick"> | ||
|
||
<StackPanel> | ||
<Canvas | ||
Width="350" Height="50"> | ||
<TextBlock | ||
x:Name="TokenLabel" | ||
Text="Token" | ||
FontSize="16" | ||
Canvas.Top="16" Canvas.Left="5"/> | ||
<TextBox | ||
x:Name="token" | ||
Text="{Binding Path= APIToken, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | ||
ToolTipService.ToolTip="Mobile Center API Token" | ||
Width="200" | ||
Canvas.Top="10" Canvas.Left="85"/> | ||
</Canvas> | ||
</StackPanel> | ||
</ContentDialog> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Windows.UI.Xaml.Controls; | ||
|
||
// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 | ||
|
||
namespace HoloLensCommander | ||
{ | ||
public sealed partial class SetAPItokenDialog : ContentDialog | ||
{ | ||
private UserToken apiToken; | ||
|
||
public SetAPItokenDialog(UserToken APItoken) | ||
{ | ||
this.apiToken = APItoken; | ||
this.DataContext = new SetAPItokenDialogViewModel(APItoken); | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) | ||
{ | ||
((SetAPItokenDialogViewModel)this.DataContext).UpdateAPItoken(this.apiToken); | ||
} | ||
|
||
private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) | ||
{ | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace HoloLensCommander | ||
{ | ||
public partial class SetAPItokenDialogViewModel : INotifyPropertyChanged | ||
{ | ||
/// <summary> | ||
/// Event that is notified when a property value has changed. | ||
/// </summary> | ||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
public SetAPItokenDialogViewModel(UserToken apiToken) | ||
{ | ||
this.APIToken= apiToken.ApiToken; | ||
} | ||
|
||
/// <summary> | ||
/// Sends the PropertyChanged events to registered handlers. | ||
/// </summary> | ||
/// <param name="propertyName">The name of property that has changed.</param> | ||
private void NotifyPropertyChanged(string propertyName) | ||
{ | ||
this.PropertyChanged?.Invoke( | ||
this, | ||
new PropertyChangedEventArgs(propertyName)); | ||
} | ||
|
||
internal void UpdateAPItoken(UserToken apiToken) | ||
{ | ||
apiToken.ApiToken = this.APIToken; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace HoloLensCommander | ||
{ | ||
public partial class SetAPItokenDialogViewModel | ||
{ | ||
private string apiToken = string.Empty; | ||
public string APIToken | ||
{ | ||
get | ||
{ | ||
return this.apiToken; | ||
} | ||
set | ||
{ | ||
if (this.apiToken!=value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this.apiToken != value |
||
{ | ||
this.apiToken = value; | ||
this.NotifyPropertyChanged(nameof(APIToken)); | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace HoloLensCommander | ||
{ | ||
public class UserToken | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think we will need anything other than the token string? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @davidkline-ms No, so far I have only needed the token. I am also working to add username and password support, but am using a NetworkCredentials object for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe encapsulate everything here (network credential / token string)? i definitely recommend requiring the user to enter credentials at least on first use during a session. these credentials would pose a security risk. As an asside, i am considering removing the device portal credential storage in a future release There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I agree it should definitely not be stored as plain text. What about storing it as a secure string? What kind of credential manager is built in to UWP apps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SecureString may work, but I haven't tried storing it in a config file. Havent researched credential manangement in UWP apps. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://docs.microsoft.com/en-us/appcenter/api-docs/ This is what we're attempting to use. App Center recommends issuing a token to make API calls. I can't find any docs on app center for how to use OAuth. Do you know how? |
||
{ | ||
public UserToken(string apiToken) | ||
{ | ||
ApiToken = apiToken; | ||
} | ||
|
||
public string ApiToken { get; set; } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to get rid of this method by not specifying a click event for the secondary button. This is what the Connect to Device dialog does.