本文整理汇总了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);
}
示例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 */
}
});
}
示例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();
}