+//{+oauth2"OAuth2 サービスの定義"(OAuth2外部サービスを定義し、認可プロセス・xhrの署名を自動化します)[+xhr]
var X_NET_OAUTH2_detection = new Function( 'w', 'try{return w.location.search}catch(e){}' ),
X_NET_OAUTH2_authorizationWindow,
X_NET_OAUTH2_authorizationTimerID;
h = pair[ 'authorizeWindowHeight' ] || 500;
X_NET_OAUTH2_authorizationWindow = window.open(
- url + ( ( url.indexOf( '?' ) !== -1 ) ? '&' : '?' ) + X_URL_objToParam(
+ X_URL_create( url,
{
'response_type' : 'code',
'client_id' : pair[ 'clientID' ],
'redirect_uri' : pair[ 'redirectURI' ],
'scope' : ( pair[ 'scopes' ] || []).join(' ')
}
- ), 'oauthauthorize',
+ ),
+ 'oauthauthorize',
'width=' + w
+ ',height=' + h
+ ',left=' + ( screen.width - w ) / 2
};
function X_Net_OAuth2_responceHandler( e ){
- var data = e.data,
+ var data = e.response,
pair = X_Pair_get( this ),
isRefresh = pair.oauth2State === 3;
if( isRefresh && data.error ){
_removeRefreshToken( this );
pair.oauth2State = 0;
- this[ 'asyncDispatch' ]( { type : X_EVENT_ERROR, message : 'Refresh access token error.' + data.error, data : data } );
+ this[ 'asyncDispatch' ]( { type : X_EVENT_ERROR, message : 'Refresh access token error.' } );
this[ 'asyncDispatch' ]( X_EVENT_NEED_AUTH );
return;
} else
if( data.error ){
pair.oauth2State = 0;
- this[ 'asyncDispatch' ]( { type : X_EVENT_ERROR, message : 'Get new access token error.' + data.error, data : data } );
+ this[ 'asyncDispatch' ]( { type : X_EVENT_ERROR, message : 'Get new access token error.' } );
this[ 'asyncDispatch' ]( X_EVENT_NEED_AUTH );
return;
};
headers;
if( token && mechanism === 'param' ){
- request[ 'url' ] = url + ((url.indexOf('?') !== -1) ? '&' : '?') + 'bearer_token=' + encodeURIComponent( token );
+ request[ 'url' ] = X_URL_create( url, { 'bearer_token' : encodeURIComponent( token ) } );
};
if( token && ( !mechanism || mechanism === 'header' ) ){
return pair[ name ];
};
+//}+oauth2
\ No newline at end of file