I'm using oauth.io (https://oauth.io/) to authenticate users via google, facebook, etc. How can I subscribe user to youtube channel after authentication ?
OAuth.popup(provider, function(error, result) {
// some code to subscribe user to youtube channel
});
To subscribe a user to a youtube channel, you need to make sure that you have added the following scopes for Youtube to your OAuth.io app:
https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/youtubepartner
Also make sure that the Youtube API is activated in your Google API console.
Then, you can subscribe the user through OAuth.io like this:
OAuth.popup('youtube')
.done(function (requestObject) {
requestObject.post('/youtube/v3/subscriptions?part=snippet', {
data: JSON.stringify({
snippet: {
resourceId: {
channelId: 'id_of_the_channel'
}
}
}),
dataType: 'json',
contentType: 'application/json; charset=utf8'
})
.done(function (r) {
// Success: the subscription was successful
console.log(r);
})
.fail(function (e) {
// Failure: the id was wrong, or the subscription is a duplicate
console.log(e);
});
})
.fail(function (e) {
// Handle errors here
console.log(e);
});
You need to specify the dataType and contentType fields as Google API doesn't accept form encoded data.
You can find more information about this Google API endpoint there:
https://developers.google.com/youtube/v3/docs/subscriptions/insert
And if you want to learn more about OAuth.io, you can consult the documentation here:
https://oauth.io/docs/overview
You'll also find a tutorial about the JavaScript SDK here:
https://oauth.io/getting-started?javascript&None
Hope this helps :)
Related
I'm working with two individual mvc application like A and B. I'm running these two application on localhost(IIS). On application A i have an api controller called student. Now i want these student data through student api and show on application B. How can i retrieve those data through this student api?
i try this ajax request from application B,
$.ajax({
url: 'http://localhost:123/api/StudentApi',
type: "GET",
dataType: "json",
success: function (data) {
console.log(data);
},
error: function (xhr) {
alert(xhr.responseText);
}
});
I am trying to create a new channel using slack api https://api.slack.com/methods/channels.join but getting this response
info: ** API CALL: https://slack.com/api/channels.join
Response : { ok: false, error: 'user_is_bot' }
I tried this
controller.hears('hello', ['direct_message', 'direct_mention', 'mention'], function (bot, message) {
bot.api.channels.join({'name':'nag'}, function (err, response) {
console.log("Response : ",response);
})
});
If I am mistaken please let me know. I have started learning slack api.
The reason you are getting user_is_bot is that channels.join can not be used by a bot user. As it says in the documentation for this method:
user_is_bot: This method cannot be called by a bot user.
To create channel you will want to use channels.create. However, that method can also not be used by a bot user.
The common solution is to use the full access_token, not the bot_access_token that your Slack app received from Slack after installing it with OAuth for all methods that bot users can not use, e.g. creating a new channel.
Here is the example from the OAuth documentation on how the response from Slack with both tokens look like:
{
"access_token": "xoxp-XXXXXXXX-XXXXXXXX-XXXXX",
"scope": "incoming-webhook,commands,bot",
"team_name": "Team Installing Your Hook",
"team_id": "XXXXXXXXXX",
"incoming_webhook": {
"url": "https://hooks.slack.com/TXXXXX/BXXXXX/XXXXXXXXXX",
"channel": "#channel-it-will-post-to",
"configuration_url": "https://teamname.slack.com/services/BXXXXX"
},
"bot":{
"bot_user_id":"UTTTTTTTTTTR",
"bot_access_token":"xoxb-XXXXXXXXXXXX-TTTTTTTTTTTTTT"
}
}
When I trying to retrieve some data from MS Graph I get the following error:
{error: {code: "InvalidAuthenticationToken", message: "Access token validation failure.",…}}
error:{code: "InvalidAuthenticationToken", message: "Access token validation failure.",…}
code:"InvalidAuthenticationToken"
innerError:{request-id: " xxx ", date: "2016-11-28T10:25:52"}
date : "2016-11-28T10:25:52"
request-id: " xxx "
message : "Access token validation failure."
The application is a SharePoint Add-In which should read some user and group information from Office 365.
I use the follwoing code to retrieve the data:
$.ajax({
type: "GET",
url: "https://graph.microsoft.com/v1.0/me/",
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer' + token
}
}).done(function (response) {
console.log(response);
//alert(response);
}).fail(function () {
console.log('Error occurred.');
});
For authenication I use adal.js. After login() I get the id_token. When the request is made the token is passed to the function.
Does anyone has the same issue and could help?
Thanks in advance!
To call the Microsoft Graph REST, we need to provide the access token. The id_token is used by client to verify the sign-in user.
To acquire the deligate access token for the Microsoft Graph REST, we need to make two request. The first request is get the Authorization Code from authorization endpoint. The second request is that exchange the token using the code get from the first request. About the detail request, you can refer the link below:
Microsoft Graph app authentication using Azure AD
How to use the REST API of twitter last version with sencha touch 2.x ?
To make requests for some remote api you can use Ext.Ajax.request();
Ext.Ajax.request({
url: 'https://api.twitter.com/1.1/statuses/show.json',
method: 'GET',
params: {
id: 'someId'
},
success: function ( repsonse ) {
},
failure: function ( response ) {
}
});
But be aware of Same-origin policy.
I am wondering if it is possible to send push notifications to different IOS applications from only one IOS application via Parse.com API. I can already send a push notification in same application but I want to send to different applications of mine, from a single application.
You can technically use the REST API from Cloud Code, calling back in to Parse with different headers.
Parse.Cloud.httpRequest({
method: "POST",
headers: {
"X-Parse-Application-Id": YOUR_APP_ID,
"X-Parse-REST-API-Key": REST_API_KEY,
"Content-Type": "application/json"
},
body: {
"data": {
"alert": "Yo"
}
},
url: "https://api.parse.com/1/push"
}).then(function() {
console.log("Successful push");
}, function(error) {
console.log(error);
});
Taken from official forums here: Click here