Advertisement
Guest User

Untitled

a guest
Mar 12th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. $scope.myForm={};
  2. $scope.loginData = function(){
  3. $scope.userName = $scope.myForm.firstName;
  4. $scope.password = $scope.myForm.lastName ;
  5. var ClientOAuth2 = require('client-oauth2');
  6. var githubAuth = new ClientOAuth2({
  7. clientId: 'sWm1ckF8pEjjPXsF6T0TaEY5E4Aa',
  8. clientSecret: 'LtfWCxqaEqvavbjFUzeLlq2FbMMa',
  9. accessTokenUri: 'https://10.37.3.24:8243/token',
  10. authorizationUri: ': http://10.37.3.24:8280/devicegateway/v1/getuser/admin',
  11. redirectUri: 'http://tutorials.jenkov.com/angularjs/forms.html',
  12. scopes: ['notifications', 'gist']
  13. });
  14. var token = githubAuth.createToken('access token', 'optional refresh token', 'optional token type', { data: 'raw user data' });
  15.  
  16. // Set the token TTL.
  17. token.expiresIn(1234); // Seconds.
  18. token.expiresIn(new Date('2016-03-13')) ;// Date.
  19.  
  20. // Refresh the users credentials and save the new access token and info.
  21. token.refresh().then(storeNewToken);
  22.  
  23. // Sign a standard HTTP request object, updating the URL with the access token
  24. // or adding authorization headers, depending on token type.
  25. token.sign({
  26. method: 'get',
  27. url: 'https://api.github.com/users'
  28. }) //=> { method, url, headers, ... }
  29. githubAuth.owner.getToken($scope.myForm.firstName, $scope.myForm.lastName)
  30. .then(function (user) {
  31. console.log(user) //=> { accessToken: '...', tokenType: 'bearer', ... }
  32. });
  33.  
  34.  
  35. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement