Skip to main content

Obtaining an OAuth Token

This snippet demonstrates how your apps can use simple username and password, also known as resource owner password credentials (ROPC) to obtain an OAuth token.

public void getOAuthToken() {

    final String username = "yourUsername";
    final String password = "yourPassword";
    final String hostname = "https://yourserver/mga/sps/oauth/oauth20/token"
    final boolean ignoreSsl = false;
    final String clientId = "yourClientId"

    OAuthContext.sharedInstance().authorize(hostname, clientId, username, password, ignoreSsl, new IResultCallback<OAuthToken>() {
        public void handleResult(OAuthToken oAuthToken, VerifySdkException e) {

            if (e == null)  {
                // we got the token
                Log.i("Token", oAuthToken.getAccessToken())
            else {
                Log.e("Error", e.toString());