OAuth2 Session Create
Description
Used to create a new session (login the user) via third party authentication (currently Google or Slack). Returns a new SessionId
for the first user in OnSIP's system associated with the email address for the third party user. If more OnSIP users are associated with this email address, use OAuth2SessionReplaceUser to switch which user the SessionId is associated with. The SessionId
is returned in the Session
node of the response.
Authentication & Authorization
Not required.
Request Parameters
This request has two different potential uses.
Required Parameters |
Description |
Action |
“OAuth2SessionCreate” |
Service |
"SlackLogin" or "GoogleLogin" (depending on which supported service you use) |
Optional Parameters |
Description |
Output |
"json" or “xml” |
This request has two different potential uses. The first case is if an Authorization Code was just received from a third party :
Required Parameters |
Description |
AuthorizationCode |
The code which the third party passes back to confirm successful authorization. |
RedirectUri |
The uri known to the third party, where the oauth requests complete to. This does not need to be functional for OnSIP, but the uri must be passed and acceptable. |
The second case occurs if the OAuth Token and other specifics are already known about the third party and OnSIP user.
Required Parameters |
Description |
ServiceUserId |
The Id of the User in the third party's system. |
UserId |
The OnSIP User Id chosen to associate to this service user. |
OAuthToken |
The Token passed from the third party. |
Sample Request
cURL
1
2
3
4
|
curl -X POST \
--data \
'Action=OAuth2SessionCreate&ServiceName=SlackLogin&AuthorizationCode=2398830389.42d7954edbe&RedirectUri=https://app.onsip.com/app/oauth2/&Output=xml' \
https://api.onsip.com/api
|
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
|
var data = new FormData();
data.append('Action', 'OAuth2SessionCreate');
data.append('AuthorizationCode', '2398830389.42d795edbe');
data.append('RedirectUri', 'https://app.onsip.com/app/oauth2');
data.append('ServiceName', 'SlackLogin');
data.append('Output', 'xml');
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://api.onsip.com/api', true);
xhr.onload = function () {
console.log(this.responseText);
}
xhr.send(data);
|
Sample Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<Response xmlns="http://www.jnctn.net/ns/rest/2006-01">
<Context>
<Action>
<IsCompleted>true</IsCompleted>
</Action>
<Request>
<DateTime>2018-03-06T20:00:11+00:00</DateTime>
<Duration>230</Duration>
<IsValid>true</IsValid>
<Parameters>
<Parameter>
<Name>Service</Name>
<Value>SlackLogin</Value>
</Parameter>
<Parameter>
<Name>AuthorizationCode</Name>
<Value>2398830389.325703368117.118c2490555555559e353fb8957681129f8c40def28e9d1f1f39d5d7b8a</Value>
</Parameter>
<Parameter>
<Name>RedirectUri</Name>
<Value>https://app.onsip.com/app/oauth2/</Value>
</Parameter>
<Parameter>
<Name>Action</Name>
<Value>OAuth2SessionCreate</Value>
</Parameter>
<Parameter>
<Name>Output</Name>
<Value>json</Value>
</Parameter>
</Parameters>
</Request>
<Session>
<IsEstablished>true</IsEstablished>
<Roles>
<Role>
<Name>User</Name>
</Role>
<Role>
<Name>Organization Viewer</Name>
</Role>
</Roles>
<SessionId>usHVsKXDzI555555555gE9SrrrZ</SessionId>
<UserId>555555</UserId>
</Session>
</Context>
<Result>
<OAuth2SessionCreate>
<UserOAuth2AccessToken>
<Scope>55555555555555</Scope>
<Service>SlackLogin</Service>
<ServiceUserId>U55555555</ServiceUserId>
<Token>xoxp-5555555-5555555-309389273104-21fef0dbdaa62668bee2208d946386de</Token>
<UserId>151764</UserId>
<UserOAuth2AccessTokenId>555555</UserOAuth2AccessTokenId>
</UserOAuth2AccessToken>
<UserSummaries>
<UserSummary>
<AccountId>5555</AccountId>
<Addresses>
<Address>
<Address>fake@junctionnetworks.com</Address>
<Statuses />
</Address>
</Addresses>
<Aliases>
<Alias>73247</Alias>
</Aliases>
<AuthUsername>fake_auth</AuthUsername>
<ContactEmail>fake@onsip.com</ContactEmail>
<ContactName>Fake Name</ContactName>
<ContactPhone>1-555-555-3350</ContactPhone>
<E164Aliases />
<OrganizationId>5555</OrganizationId>
<Status>enabled</Status>
<UserId>555555</UserId>
</UserSummary>
</UserSummaries>
</OAuth2SessionCreate>
</Result>
</Response>
|
OAuth2 Session Replace User
Description
Used to create a replace the OnSIP user of an OAuth session with another OnSIP user associated with that OAuth session's service user's email address.
Authentication & Authorization
Request Parameters
This request has two different potential uses.
Required Parameters |
Description |
Action |
“OAuth2SessionReplaceUser” |
Service |
"SlackLoginDummy" or "GoogleLoginDummy" (depending on which supported service you use) |
ServiceUserId |
The Id of the User in the third party's system. |
UserId |
The OnSIP User Id chosen to associate to this service user. |
OAuthToken |
|
Optional Parameters |
Description |
Output |
"json" or “xml” |
Sample Request
cURL
1
2
3
4
|
curl -X POST \
--data \
'Action=OAuth2SessionReplaceUser&SessionId=usHVsKXDzI9qQNKpzNUqkFADgE95555&UserId=234565&Service=SlackDummyLogin&ServiceUserId=U324123&OAuthToken=xoxp-2398830389-935552277-3093855551 \
https://api.onsip.com/api
|
JavaScript
1
2
3
4
5
6
7
8
|
var data = new FormData();
data.append('Action', 'OAuth2SessionReplaceUser');
data.append('SessionId', 'usH2314asfd234'); data.append('UserId', '12345423'); data.append('ServiceUserId', 'U234234'); data.append('Service', 'SlackDummyLogin'); data.append('OAuthToken', 'xoxp-2342342237-23424243'); var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://api.onsip.com/api', true); xhr.onload = function () { console.log(this.responseText); } xhr.send(data);
|
Sample Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<Response xmlns="http://www.jnctn.net/ns/rest/2006-01">
<Context>
<Action>
<IsCompleted>true</IsCompleted>
</Action>
<Request>
<DateTime>2018-03-06T21:15:29+00:00</DateTime>
<Duration>96</Duration>
<IsValid>true</IsValid>
<Parameters>
<Parameter>
<element>
<Name>SessionId</Name>
<Value>rRrpBu35555rb6eiNxwPXRj5UX</Value>
</element>
<element>
<Name>UserId</Name>
<Value>155555</Value>
</element>
<element>
<Name>Service</Name>
<Value>SlackLoginDummy</Value>
</element>
<element>
<Name>ServiceUserId</Name>
<Value>U0955555</Value>
</element>
<element>
<Name>OAuthToken</Name>
<Value>******</Value>
</element>
<element>
<Name>Action</Name>
<Value>OAuth2SessionReplaceUser</Value>
</element>
<element>
<Name>Output</Name>
<Value>json</Value>
</element>
</Parameter>
</Parameters>
</Request>
<Session>
<IsEstablished>true</IsEstablished>
<Roles>
<Role>
<Name>Account Admin</Name>
</Role>
</Roles>
<SessionId>rRrp5555555wPXRj5UX</SessionId>
<UserId>155555</UserId>
</Session>
</Context>
<Result>
<OAuth2SessionReplaceUser>
<UserOAuth2AccessToken>
<Scope>5e6c6875555555555555555593be1e8c32c451891</Scope>
<Service>SlackLogin</Service>
<ServiceUserId>U05555555</ServiceUserId>
<Token>xoxp-23555555-93070555577-3093855554-21fef0dbdaa5555208d946386de</Token>
<UserId>155555</UserId>
<UserOAuth2AccessTokenId>1555558</UserOAuth2AccessTokenId>
</UserOAuth2AccessToken>
<UserSummary>
<AccountId>225553</AccountId>
<Addresses>
<Address>
<Address>fake@onsip.com</Address>
<Statuses />
</Address>
</Addresses>
<Aliases>
<Alias>
7001
</Alias>
</Aliases>
<AuthUsername>fake</AuthUsername>
<ContactEmail>fake@onsip.com</ContactEmail>
<ContactName>Fake Name</ContactName>
<ContactPhone>1-555-555-55555</ContactPhone>
<E164Aliases />
<OrganizationId>55555</OrganizationId>
<Status>enabled</Status>
<UserId>55555</UserId>
</UserSummary>
</OAuth2SessionReplaceUser>
</Result>
</Response>
|