Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ var myInitOptions : tnsOAuthModule.ITnsOAuthCredentials = {
authorizeEndpoint: '/my/authorize/endpoint'
tokenEndpoint: '/my/token/endpoint',
clientId: 'myClientId',
clientSecret: 'my-client-secret,
clientSecret: 'my-client-secret',
redirectUri: 'myAppDomain://callback',
responseType: 'my tokens',
scope: 'my requested scopes',
Expand Down
1 change: 1 addition & 0 deletions tns-oauth-interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ITnsOAuthCredentials {
redirectUri: string;
responseType?: string;
scope: string;
resource?: string;
}

export interface ITnsOAuthCredentialsUaa extends ITnsOAuthCredentials {
Expand Down
19 changes: 12 additions & 7 deletions tns-oauth.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/// <reference path="references.d.ts" />


import * as querystring from 'querystring';
import * as URL from 'url';
import * as http from 'http';
import * as trace from "trace";
import * as frameModule from 'ui/frame';
import * as platform from 'platform';
import * as utils from './tns-oauth-utils';
import * as querystring from 'querystring';
import * as frameModule from 'ui/frame';
import * as URL from 'url';
import * as TnsOAuthModule from './tns-oauth-interfaces';
import { TnsOAuthPageProvider } from './tns-oauth-page-provider';
import { TnsOAuthTokenCache } from './tns-oauth-token-cache';
import * as TnsOAuthModule from './tns-oauth-interfaces';
import * as utils from './tns-oauth-utils';

export var ACCESS_TOKEN_CACHE_KEY = 'ACCESS_TOKEN_CACHE_KEY';
export var REFRESH_TOKEN_CACHE_KEY = 'REFRESH_TOKEN_CACHE_KEY';
Expand Down Expand Up @@ -87,14 +86,20 @@ export function getTokenFromRefreshToken(credentials: TnsOAuthModule.ITnsOAuthCr
* @return {string} a fully formed uri with which authentication can be completed
*/
export function getAuthUrl(credentials: TnsOAuthModule.ITnsOAuthCredentials): string {
return credentials.authority + credentials.authorizeEndpoint +
let url = credentials.authority + credentials.authorizeEndpoint +
'?client_id=' + credentials.clientId +
'&response_type=code' +
'&redirect_uri=' + credentials.redirectUri +
'&scope=' + credentials.scope +
'&response_mode=query' +
'&nonce=' + utils.newUUID() +
'&state=abcd';

if (credentials.resource) {
url = url + '&resource=' + encodeURIComponent(credentials.resource);
}

return url;
}

export function getTokenFromCache() {
Expand Down