Bonjour,

j'ai récupéré un bout de code écrit en c# qui permet de gérer l'authentification et la génération de token :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
            var identity = new ClaimsIdentity(context.Options.AuthenticationType);
            identity.AddClaim(new Claim(ClaimTypes.Name, user.Guid.ToString()));
            identity.AddClaim(new Claim(ClaimTypes.Role, "user"));
            identity.AddClaim(new Claim("guid", user.Guid.ToString()));;
 
            var props = new AuthenticationProperties(new Dictionary<string, string>
                {
                    {
                        "as:client_id", (context.ClientId == null) ? string.Empty : context.ClientId
                    },
                    {
                        "userName", context.UserName
                    },
                    {
                        "guid", user.Guid.ToString()
                    },
                    {
                        "pseudo", user.Pseudo
                    }
                });
 
            var ticket = new AuthenticationTicket(identity, props);
            context.Validated(ticket);
J'ai un service Angular dans lequel j'essaye de récupérer le pseudo et GUID, mais rien y fait :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
        $http.post(serviceBase + 'token', data, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).success(function (response) {
            $log.log('posted');
            $log.log(response);
            $log.log(response.pseudo); // retourne null
            $log.log(response.userName); //retourne null
            localStorageService.set('authorizationData', { token: response.access_token, pseudo: response.pseudo});
            _authentication.isAuth = true;
            _authentication.pseudo = response.pseudo; // récupère rien !!!
            _authentication.userName = response.userName; // récupère rien !!!
 
            deferred.resolve(response);
Quelqu'un aurait-il une idée ?
Merci d'avance