简体   繁体   中英

Using Digits by twitter in Android

I'd like to uses newly introduced Login Provider, Digits by Twitter. Everything works fine till the time I wanted to verify user credentials on a third party server (Amazon Cognito in my case) as described here .

TwitterAuthConfig authConfig = TwitterCore.getInstance().getAuthConfig();
TwitterAuthToken authToken = session.getAuthToken();

OAuthSigning oauthSigning = new OAuthSigning(authConfig, authToken);

in my case session.getAuthToken(); returns an instance of AuthToken not TwitterAuthToken which then I cannot pass it to OAuthSigning()

You can simply cast the AuthToken to TwitterAuthToken. If you are using with Amazon Cognito you can use a block similiar to the following:

   @Override
   public void success(DigitsSession session, String phoneNumber) {
       TwitterAuthToken authToken = (TwitterAuthToken)session.getAuthToken();
       String value = authToken.token + ";" + authToken.secret;
       Map<String, String> logins = new HashMap<String, String>();
       logins.put("www.digits.com", value);
       // Note: This overrides any existing logins
       credentialsProvider.setLogins(logins);
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM