8
8
using Microsoft . AspNetCore . Authentication ;
9
9
using Microsoft . AspNetCore . Authentication . OAuth ;
10
10
using Microsoft . AspNetCore . Http ;
11
+ using static AspNet . Security . OAuth . Twitch . TwitchAuthenticationConstants ;
11
12
12
13
namespace AspNet . Security . OAuth . Twitch
13
14
{
@@ -25,10 +26,52 @@ public TwitchAuthenticationOptions()
25
26
TokenEndpoint = TwitchAuthenticationDefaults . TokenEndpoint ;
26
27
UserInformationEndpoint = TwitchAuthenticationDefaults . UserInformationEndpoint ;
27
28
28
- Scope . Add ( "user_read " ) ;
29
+ Scope . Add ( "user:read:email " ) ;
29
30
30
- ClaimActions . MapJsonKey ( ClaimTypes . NameIdentifier , "_id" ) ;
31
- ClaimActions . MapJsonKey ( ClaimTypes . Name , "name" ) ;
31
+ ClaimActions . MapCustomJson ( ClaimTypes . NameIdentifier , user =>
32
+ {
33
+ return user [ "data" ] ? [ 0 ] ? . Value < string > ( "id" ) ;
34
+ } ) ;
35
+
36
+ ClaimActions . MapCustomJson ( ClaimTypes . Name , user =>
37
+ {
38
+ return user [ "data" ] ? [ 0 ] ? . Value < string > ( "login" ) ;
39
+ } ) ;
40
+
41
+ ClaimActions . MapCustomJson ( Claims . DisplayName , user =>
42
+ {
43
+ return user [ "data" ] ? [ 0 ] ? . Value < string > ( "display_name" ) ;
44
+ } ) ;
45
+
46
+ ClaimActions . MapCustomJson ( ClaimTypes . Email , user =>
47
+ {
48
+ return user [ "data" ] ? [ 0 ] ? . Value < string > ( "email" ) ;
49
+ } ) ;
50
+
51
+ ClaimActions . MapCustomJson ( Claims . Type , user =>
52
+ {
53
+ return user [ "data" ] ? [ 0 ] ? . Value < string > ( "type" ) ;
54
+ } ) ;
55
+
56
+ ClaimActions . MapCustomJson ( Claims . BroadcasterType , user =>
57
+ {
58
+ return user [ "data" ] ? [ 0 ] ? . Value < string > ( "broadcaster_type" ) ;
59
+ } ) ;
60
+
61
+ ClaimActions . MapCustomJson ( Claims . Description , user =>
62
+ {
63
+ return user [ "data" ] ? [ 0 ] ? . Value < string > ( "description" ) ;
64
+ } ) ;
65
+
66
+ ClaimActions . MapCustomJson ( Claims . ProfileImageUrl , user =>
67
+ {
68
+ return user [ "data" ] ? [ 0 ] ? . Value < string > ( "profile_image_url" ) ;
69
+ } ) ;
70
+
71
+ ClaimActions . MapCustomJson ( Claims . OfflineImageUrl , user =>
72
+ {
73
+ return user [ "data" ] ? [ 0 ] ? . Value < string > ( "offline_image_url" ) ;
74
+ } ) ;
32
75
}
33
76
}
34
77
}
0 commit comments