Refactored and fixed device code sample#1
Conversation
|
consider sharing code between the samples and refactor usernamepwd flow to match what you added for device code... or build one sample that can do both and ask for the user for a key to pick auth method |
|
Do you mind adding a bit more to the readme file on how to run the samples? |
Added in this commit. |
Added this in this commit. |
sangonzal
left a comment
There was a problem hiding this comment.
Overall looks great. Thank for cleaning up.
Also one more thing that we need to have a full device code implementation:
- A mechanism so that callers can cancel polling. While the polling is happening, the caller should be able to set cancel to true and that would cause the MSAL to break out of the polling loop.
|
In this new commit, the following changes have been made:
|
sangonzal
left a comment
There was a problem hiding this comment.
Great progress. A couple of questions.
| authParams.SetAuthorizationType(msalbase.AuthorizationTypeDeviceCode) | ||
| } | ||
|
|
||
| func (p *AcquireTokenDeviceCodeParameters) InternalCallback(dcr *msalbase.DeviceCodeResult) { |
There was a problem hiding this comment.
Do we need an internal callback? Can we just call deviceCodeCallback directly?
There was a problem hiding this comment.
This is to cast it to the interface IDeviceCodeResult. The internal library returns a DeviceCodeResult, and to make it accessible to the user, we utilize IDeviceCodeResult.
There was a problem hiding this comment.
Can we use the interface in the method signatures internally as well? We should try to use the interface wherever possible.
There was a problem hiding this comment.
The interface is not accessible to the internal package. The DeviceCodeRequest uses this callback and passes in a DeviceCodeResult, which this InternalCallback casts to the interface type IDeviceCodeResult.
There was a problem hiding this comment.
Can we make the interface accessible to the internal package?
| } | ||
|
|
||
| req.authParameters.SetAuthorityEndpoints(endpoints) | ||
| deviceCodeResult, err := req.webRequestManager.GetDeviceCodeResult(req.authParameters) |
There was a problem hiding this comment.
Can we update GetDeviceCodeResult to return IDeviceCodeResult? In line 50, req.deviceCodeCallback() can then be updated to be the callback set by the developer, instead of the internal callback?
| authParams.SetAuthorizationType(msalbase.AuthorizationTypeDeviceCode) | ||
| } | ||
|
|
||
| func (p *AcquireTokenDeviceCodeParameters) InternalCallback(dcr *msalbase.DeviceCodeResult) { |
There was a problem hiding this comment.
Can we make the interface accessible to the internal package?
src/examples/devicecodeflow/main.goauthorization_pendingandslow_downerrors