當前位置: 首頁>>代碼示例>>Java>>正文


Java AuthorizeResult類代碼示例

本文整理匯總了Java中com.amazon.identity.auth.device.api.authorization.AuthorizeResult的典型用法代碼示例。如果您正苦於以下問題:Java AuthorizeResult類的具體用法?Java AuthorizeResult怎麽用?Java AuthorizeResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AuthorizeResult類屬於com.amazon.identity.auth.device.api.authorization包,在下文中一共展示了AuthorizeResult類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSuccess

import com.amazon.identity.auth.device.api.authorization.AuthorizeResult; //導入依賴的package包/類
@Override
public void onSuccess(final AuthorizeResult authorizeResult) {
    final String authorizationCode = authorizeResult.getAuthorizationCode();
    final String redirectUri = authorizeResult.getRedirectURI();
    final String clientId = authorizeResult.getClientId();
    CLIENTID = clientId;

            SharedPreferences.Editor  preferences = Util.getPrefernces(myContext).edit();
            preferences.putString("clientID",clientId);
            preferences.apply();
            RequestBody formBody = new FormBody.Builder()
                    .add("grant_type", "authorization_code")
                    .add("code", authorizationCode)
                    .add("redirect_uri", redirectUri)
                    .add("client_id", clientId)
                    .add("code_verifier", codeVerifier)
                    .build();

            tokenHanlder.doPostRequest(formBody,TokenHandler.FirstMainActivityDoPostRequest);

}
 
開發者ID:raj10071997,項目名稱:Alexa-Voice-Service,代碼行數:22,代碼來源:MainActivity.java

示例2: onStart

import com.amazon.identity.auth.device.api.authorization.AuthorizeResult; //導入依賴的package包/類
@Override
protected void onStart() {
    super.onStart();
    Scope[] scopes = {ProfileScope.profile(), ProfileScope.postalCode()};
    AuthorizationManager.getToken(this, scopes, new Listener<AuthorizeResult, AuthError>() {
        @Override
        public void onSuccess(AuthorizeResult result) {
            if (result.getAccessToken() != null) {
                /* The user is signed in */
                fetchUserProfile();
            } else {
                /* The user is not signed in */
            }
        }

        @Override
        public void onError(AuthError ae) {
            /* The user is not signed in */
        }
    });
}
 
開發者ID:dazcode,項目名稱:smart-device-cloud,代碼行數:22,代碼來源:LoginWithAmazonActivity.java

示例3: onCreate

import com.amazon.identity.auth.device.api.authorization.AuthorizeResult; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    requestContext = RequestContext.create(this);
    requestContext.registerListener(new AuthorizeListener() {

        @Override
        public void onSuccess(AuthorizeResult authorizeResult) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {

                    setLoggingInState(true);
                }
            });
            fetchUserProfile();
        }


        @Override
        public void onError(AuthError authError) {
            Log.e(TAG, "AuthError during authorization", authError);
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    utilities.showToast("Error during authorization.  Please try again.", getApplicationContext());
                    resetProfileView();
                    setLoggingInState(false);
                }
            });
        }


        @Override
        public void onCancel(AuthCancellation authCancellation) {
            Log.e(TAG, "User cancelled authorization");
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    utilities.showToast("Authorization cancelled.", getApplicationContext());
                    resetProfileView();
                }
            });
        }
    });

    setContentView(R.layout.login_with_amazon);

    initializeUI();
}
 
開發者ID:dazcode,項目名稱:smart-device-cloud,代碼行數:53,代碼來源:LoginWithAmazonActivity.java


注:本文中的com.amazon.identity.auth.device.api.authorization.AuthorizeResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。