Skip to content

Commit

Permalink
Huawei provider tweaks
Browse files Browse the repository at this point in the history
- Rename `FetchNickName` to `FetchNickname`.
- Add missing XML documentation.
- Remove documentation copied from Huawei that isn't provider-specific.
  • Loading branch information
martincostello committed Nov 1, 2022
1 parent cd594d9 commit 02cd475
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
13 changes: 4 additions & 9 deletions docs/huawei.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ services.AddAuthentication(options => /* Auth configuration */)
options.ClientId = "my-client-id";
options.ClientSecret = "my-client-secret";

// Optionally.
// Optionally return the user's profile and email address
options.Scope.Add("profile");
options.Scope.Add("email");

// Optionally.
options.FetchNickName = true;
// Optionally get the user's nickname
options.FetchNickname = true;
});
```

Expand All @@ -26,9 +26,4 @@ _None._

| Property Name | Property Type | Description | Default Value |
|:--|:--|:--|:--|
| `FetchNickName` | `bool` | When FetchNickName is set to false or not set, the anonymous account is returned. If the anonymous account is unavailable, the nickname is returned. When FetchNickName is set to true, the nickname is returned. If the nickname is unavailable, the anonymous account is returned. | `false` |

### Scope
Corresponding information, such as the profile picture and email address, can be obtained only if the app has the permission to obtain the information.
* `profile` basic information of a HUAWEI ID, such as the profile picture and nickname.
* `email` email address of a HUAWEI ID.
| `FetchNickname` | `bool` | When `false` the anonymous account is returned. If the anonymous account is unavailable, the nickname is returned. When `true`, the nickname is returned. If the nickname is unavailable, the anonymous account is returned. | `false` |
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(

var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("getNickName", Options.FetchNickName ? "1" : "0"),
new KeyValuePair<string, string>("getNickName", Options.FetchNickname ? "1" : "0"),
new KeyValuePair<string, string>("access_token", tokens.AccessToken!)
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ public HuaweiAuthenticationOptions()
Scope.Add("openid");
}

public bool FetchNickName { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to use the user's nickname, if available.
/// </summary>
public bool FetchNickname { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected internal override void RegisterAuthentication(AuthenticationBuilder bu
{
builder.AddHuawei(options =>
{
options.FetchNickName = true;
options.FetchNickname = true;
options.Scope.Add("profile");
options.Scope.Add("email");
Expand Down

0 comments on commit 02cd475

Please sign in to comment.