Ionic framework 如何使用Ionic Framework for LinkedIn实现OAuth.io?
我已经创建了LinkedIn应用程序并检索了客户端id和客户端密码 现在在OAuth.io的集成api中创建了一个api,并添加了密钥和权限范围 我想使用Ionic框架运行这个项目。应该做些什么来实现它 附言:我对爱奥尼亚框架和OAuth.io不熟悉。所以请不要介意我问这个问题的方式 整份index.html:Ionic framework 如何使用Ionic Framework for LinkedIn实现OAuth.io?,ionic-framework,linkedin,linkedin-api,oauth.io,Ionic Framework,Linkedin,Linkedin Api,Oauth.io,我已经创建了LinkedIn应用程序并检索了客户端id和客户端密码 现在在OAuth.io的集成api中创建了一个api,并添加了密钥和权限范围 我想使用Ionic框架运行这个项目。应该做些什么来实现它 附言:我对爱奥尼亚框架和OAuth.io不熟悉。所以请不要介意我问这个问题的方式 整份index.html: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <met
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="js/ng-cordova.min.js"></script>
<script src="js/ng-cordova-oauth.min.js"></script>
<script src="cordova.js"></script>
<script src="js/app.js"></script>
</head>
<body ng-controller="MainCtrl">
<button class="button" ng-click="linkedInLogin()">Login via LinkedIn</button>
</body>
</html>
我想你读了插件。我想你读了插件。请完成以下步骤和代码:
1) 以ionic start LinkedIn登录为空从终端创建项目
2) cd LinkedIn登录项目
3) 将终端中所需的平台添加为离子添加平台****
4) 在项目中的cordova.ja文件上方添加ng-cordova.min.js文件
5) 将ng cordova oauth安装为bower安装ng cordova oauth-S
6) 然后在index.html中包含ng-cordova-oauth.min.js文件
7) 将“ngCordova”和“ngcordovoauth”作为依赖项注入app.js文件
8) 在index.html中,通过linkedin创建一个登录按钮
9) 在app.js中,使用以下代码创建控制器
10) 如果上述插件不起作用,请更新您的cordova平台
$cordovaOauth.linkedin(clientId, clientSecret, ['r_basicprofile', 'r_emailaddress']).then(function(success){
//Here you will get the access_token
console.log(JSON.stringify(success));
$http({method:"GET", url:"https://api.linkedin.com/v1/people/~:(email-address,first-name,last-name,picture-url)?format=json&oauth2_access_token="+success.access_token}).success(function(response){
// In response we will get firstname, lastname, emailaddress and picture url
// Note: If image is not uploaded in linkedIn account, we can't get image url
console.log(response);
}, function(error){
console.log(error);
})
}, function(error){
console.log(error);
})
请完成以下步骤和代码:
1) 以ionic start LinkedIn登录为空从终端创建项目
2) cd LinkedIn登录项目
3) 将终端中所需的平台添加为离子添加平台****
4) 在项目中的cordova.ja文件上方添加ng-cordova.min.js文件
5) 将ng cordova oauth安装为bower安装ng cordova oauth-S
6) 然后在index.html中包含ng-cordova-oauth.min.js文件
7) 将“ngCordova”和“ngcordovoauth”作为依赖项注入app.js文件
8) 在index.html中,通过linkedin创建一个登录按钮
9) 在app.js中,使用以下代码创建控制器
10) 如果上述插件不起作用,请更新您的cordova平台
$cordovaOauth.linkedin(clientId, clientSecret, ['r_basicprofile', 'r_emailaddress']).then(function(success){
//Here you will get the access_token
console.log(JSON.stringify(success));
$http({method:"GET", url:"https://api.linkedin.com/v1/people/~:(email-address,first-name,last-name,picture-url)?format=json&oauth2_access_token="+success.access_token}).success(function(response){
// In response we will get firstname, lastname, emailaddress and picture url
// Note: If image is not uploaded in linkedIn account, we can't get image url
console.log(response);
}, function(error){
console.log(error);
})
}, function(error){
console.log(error);
})
我使用oauth.io通过linkedin实现了登录: 请按照以下步骤操作:
1.在oauth.io中创建应用程序并获取公钥。
2.单击左侧栏中的集成API菜单。
3.现在单击右上角的添加API绿色按钮。
4.现在搜索并选择LinkedIn。
5.现在在密钥和权限范围中添加客户端id和客户端机密。
6.使用以下命令将插件添加到项目:
cordova plugin add https://github.com/oauth-io/oauth-phonegap
七,。对于控制器代码,请检查以下代码
document.addEventListener( "deviceready", onDeviceReady );
function onDeviceReady( event ) {
// on button click code
$scope.linkedInLogin = function(){
OAuth.initialize('your public key')
OAuth.popup('linkedin').done(function(result) {
// Here you will get access token
console.log(result)
result.me().done(function(data) {
// Here you will get basic profile details of user
console.log(data);
})
});
};
}
希望它能对您有所帮助。使用oauth.io我已经通过linkedin实现了登录: 请按照以下步骤操作:
1.在oauth.io中创建应用程序并获取公钥。
2.单击左侧栏中的集成API菜单。
3.现在单击右上角的添加API绿色按钮。
4.现在搜索并选择LinkedIn。
5.现在在密钥和权限范围中添加客户端id和客户端机密。
6.使用以下命令将插件添加到项目:
cordova plugin add https://github.com/oauth-io/oauth-phonegap
七,。对于控制器代码,请检查以下代码
document.addEventListener( "deviceready", onDeviceReady );
function onDeviceReady( event ) {
// on button click code
$scope.linkedInLogin = function(){
OAuth.initialize('your public key')
OAuth.popup('linkedin').done(function(result) {
// Here you will get access token
console.log(result)
result.me().done(function(data) {
// Here you will get basic profile details of user
console.log(data);
})
});
};
}
希望它能对您有所帮助。我必须使用OAuth.ioI必须使用OAuth.ioI我知道这个方法。但是我必须使用OAuth.ioThis,它应该被标记为正确答案!我知道这个方法。但是我必须使用OAuth.ioThis,它应该被标记为正确答案!使用ngCordovau未在html页面中编写ng click for按钮。。编写如下代码。。通过LinkedIn登录您已经编写了两次ng click函数。。。我已经在我的控制器代码中为按钮点击编写了代码(第7步)。。。所以你只需要在你的控制器中包含我的控制器代码。。。不要在你没有提到的html页面中添加任何提取行ng app=“starter”。。。包括下面这样的内容。。你没有在html页面中编写ng click for按钮。。编写如下代码。。通过LinkedIn登录您已经编写了两次ng click函数。。。我已经在我的控制器代码中为按钮点击编写了代码(第7步)。。。所以你只需要在你的控制器中包含我的控制器代码。。。不要在你没有提到的html页面中添加任何提取行ng app=“starter”。。。包括下面这样的内容。。