cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
290
Views
0
Helpful
8
Replies
Highlighted
Beginner

Sample POST attempt to create a space in Webex Teams

am still fairly new to working with gadgets customization and using REST APIs.

I just created one method to authenticate to webex teams using the token from Webex app integration portal and am trying to use post method to create a space .Below is the section of the code under the xml file that i have under finesse desktop layout

 

<script type="text/javascript">

$(document).ready(function(){
var OAuthurl= "https://webexapis.com/v1/authorize?client_id=C68c72a161f0fc47aea5e8928be77f54d56487e6afefe38e8a79f8a3bac76f17d&response_type=code&redirect_uri=https%3A%2F%2Fhttps%3A%2F%2Feipsccxsa01.broadridge.net%3A8445%2Fdesktop%2Fcontainer%2F%3Flls&scope=spark-co...";
var win = window.open(OAuthurl);
var data= {"title": "Project Silver"};
$.post('https://webexapis.com/v1/rooms', data);
});
</script>
</body>

 

but nothing happens when the page loads, there is no page that opens up for login

under webex teams am using following as the redirect URI, not sure if that is correct

 

https://fqdn:8445/desktop/container/?lls not sure if this would be the right redirect url

8 REPLIES 8
Highlighted
Beginner

update..so the pop up appeared and it successfully authenticates me and redirects me to Finesse but the space is not created under webex teams.

Highlighted

Hi,

 

I'd suggest adding client side logging and also taking a look at the browser's developer tools to see what is going on.

 

From the code you have above, I do not see the authorization being passed in with the API request, so that request will fail. Did you see what is the HTTP status code you are getting as a result of that request? Another possible issue could be that the API request is being made before the OAuth is completed.

 

Taking a look at the developer tool will allow you to see the network traffic and see when the request is made. You can also use the developer tools to add breakpoints and see whats going on.

 

Thanx,

Denise

Highlighted

i figured that out and i changed the code to this, but no luck

<script type="text/javascript">

$(document).ready(function(){
var OAuthurl= "https://webexapis.com/v1/authorize?client_id=C68c72a161f0dc47aea5e8928be77f56d56487e6afefe38e8a79f8a3bac76f17d&response_type=code&redirect_uri=https%3A%2F%2Feipsccxsa01.broadridge.net%3A8445%2F3rdpartygadget%2Ffiles%2Foauth.html&scope=spark-complianc...";
var win = window.open(OAuthurl);
var oauthauth="https://webexapis.com/v1/authorize"
var querystring="?client_id=C68c72a161f0d647aea5e8928be77f54d56487e6afefe38e8a79f8a3bac76f17d&response_type=code&redirect_uri=https%3A%2F%2Feipsccxsa01.broadridge.net%3A8445%2F3rdpartygadget%2Ffiles%2Foauth.html&scope=spark-compliance%3Amemberships_read%20spark-admin%3Aresource_groups_read%20spark%3Aall%20spark-admin%3Apeople_write%20spark-admin%3Aroles_read%20spark-admin%3Aorganizations_read%20spark-admin%3Aplaces_read%20spark-admin%3Aresource_group_memberships_read%20spark-compliance%3Aevents_read%20spark-admin%3Aresource_group_memberships_write%20spark-admin%3Acall_qualities_read%20spark-compliance%3Amessages_write%20spark%3Akms%20spark-admin%3Adevices_read%20spark-admin%3Aplaces_write%20spark-admin%3Alicenses_read%20spark-compliance%3Amessages_read%20spark-admin%3Adevices_write%20spark-admin%3Apeople_read&state=success";

$.get(oauthauth,querystring,outdata);
function outdata(result) {
var newresult= result.slice('=')

var codenew ={
grant_type: newresult,
clinet_id: 'C68c72a161f0dc47aea5e8928be77f54d56487e6afefe38e8a79f8a3bac76f17d',
client_secret: '3dca30800a745fda0da51007eebd51ed063b0fee7d340adcb18100eb2305fd65',
code: newresult,
redirect_uri: 'https://eipsccxsa01.broadridge.net:8445/3rdpartygadget/files/oauth.html'
}
$.post('https://webexapis.com/v1/access_token', codenew);
$.post('https://webexapis.com/v1/rooms',{title: 'Unicorn'});

return false;
}
return false;
});
</script>

Highlighted

ignore the last post, this is the update code, i realised that webex returns JSON, so i had to modify the steps

<script type="text/javascript">

$(document).ready(function(){
var OAuthurl= "https://webexapis.com/v1/authorize?client_id=C68c72a161f0dc47aea5e8928be77f54d56487e6afefe38e8a79f8a3bac76f17d&response_type=code&redirect_uri=https%3A%2F%2Feipsccxsa01.broadridge.net%3A8445%2F3rdpartygadget%2Ffiles%2Foauth.html&scope=spark-complianc...";
var win = window.open(OAuthurl);
var oauthauth="https://webexapis.com/v1/authorize"
var querystring="?client_id=C68c72a161f0dc47aea5e8928be77f54d56487e6afefe38e8a79f8a3bac76f17d&response_type=code&redirect_uri=https%3A%2F%2Feipsccxsa01.broadridge.net%3A8445%2F3rdpartygadget%2Ffiles%2Foauth.html&scope=spark-compliance%3Amemberships_read%20spark-admin%3Aresource_groups_read%20spark%3Aall%20spark-admin%3Apeople_write%20spark-admin%3Aroles_read%20spark-admin%3Aorganizations_read%20spark-admin%3Aplaces_read%20spark-admin%3Aresource_group_memberships_read%20spark-compliance%3Aevents_read%20spark-admin%3Aresource_group_memberships_write%20spark-admin%3Acall_qualities_read%20spark-compliance%3Amessages_write%20spark%3Akms%20spark-admin%3Adevices_read%20spark-admin%3Aplaces_write%20spark-admin%3Alicenses_read%20spark-compliance%3Amessages_read%20spark-admin%3Adevices_write%20spark-admin%3Apeople_read&state=success";
var param= {response_type: 'Code',
client_id= 'C68c72a161f0dc47aea5e8928be77f54d56487e6afefe38e8a79f8a3bac76f17d',
redirect_uri= 'https://eipsccxsa01.broadridge.net:8445/3rdpartygadget/files/oauth.html' ,
scope= 'spark:all',
state= 'success'
}
console.group("Start of logs");
console.log("First line");
$.get(oauthauth,param,outdata);
function outdata(result) {
var newresult= result.slice(result.indexof('=')+1);
console.log("Second line");
var codenew ={
grant_type: "authorization_code",
client_id: 'C68c72a161f0dc47aea5e8928be77f54d56487e6afefe38e8a79f8a3bac76f17d',
client_secret: '3dca30800a745fda0da51007eebd51ed063b0fee7d340adcb18100eb2305fd65',
code: newresult,
redirect_uri: 'https://eipsccxsa01.broadridge.net:8445/3rdpartygadget/files/oauth.html'
}
console.log("third line");
$.postJSON('https://webexapis.com/v1/access_token', codenew);
$.postJSON('https://webexapis.com/v1/rooms',{title: 'Unicorn'});
Console.groupEnd();
return false;
}
return false;
});
</script>
</body>

 

in the console am not seeing any errors

Highlighted

Hi,

 

Have you taken a look at the webex teams announcment sample gadget? https://github.com/CiscoDevNet/finesse-sample-code/tree/master/WebexTeamsTeamAnnouncementsSampleGadget It is using the webex teams api, but to fetch messages and send messages. It shows you the oauth flow as well as the authentication code.

 

The way you have the authentication for the API request is not correct.

 

Thanx,

Denise

Highlighted

yes, that is the gadget from where i pulled the oauth.html file

 

so the question is what should be the redirect URI.

webex integration doc says your application domain suffixed by /oauth

 

in webex teams sample gadget i see you have created a separate file oauth.html

Highlighted

i see this in firewall console logs, Chrome wasn't showing me anything

 

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://idbroker.webex.com/idb/saml2/jsp/doSSO.jsp?type=login&goto=https%3A%2F%2Fidbroker.webex.com%2Fidb%2Foauth2%2Fv1%2Fauthorize%3Fresponse_type%3DCode%26client_id%3DC68c72a161f0dc47aea5e8928be77f54d56487e6afefe38e8a79f8a3bac76f17d%26redirect_uri%...

 

but i did get webex SSO login page

Highlighted

The redirect URI should be where the code that will execute to get the access token is hosted.

 

I suggest that you try to get this sample gadget working by following the steps in the PDF, then you can modify it to use the API to create a space.

 

Thanx,

Denise

Content for Community-Ad