# Android Retrieve Zoom Access Token Failure

**URL:** <https://devforum.zoom.us/t/android-retrieve-zoom-access-token-failure/29760>\
**Category:** Android\
**Created:** [September 10, 2020, 9:07am UTC](https://devforum.zoom.us/t/android-retrieve-zoom-access-token-failure/29760 "2020-09-10T09:07:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![junndobit123](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/junndobit123/32/15018_2.png) [@junndobit123](https://devforum.zoom.us/u/junndobit123)\
**Post date:** [September 10, 2020, 9:07am UTC](https://devforum.zoom.us/t/android-retrieve-zoom-access-token-failure/29760/1 "2020-09-10T09:07:03Z")

</div>

I am following this documentation: [https://marketplace.zoom.us/docs/sdk/native-sdks/android/mastering-zoom-sdk/start-join-meeting/api-user/authentication](https://marketplace.zoom.us/docs/sdk/native-sdks/android/mastering-zoom-sdk/start-join-meeting/api-user/authentication) and I successfully got the JWT and tried it on [jwt.io](http://jwt.io) to see if the token works and it did.

 ![jwt success](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/2/2401def077c898343dd37db901728854787855ef.png)

Now my problem is when I use this JWT to retrieve a Zoom Access Token (ZAK). I get a -1 in the connection.getResponseCode() meaning it will just go to the else statement. I simply just followed the code in the documentation and replaced it with my own variables.

```
try {
        URL zoomTokenEndpoint = new URL("https://api.zoom.us/v2/users/" + userId + "/token?type=zak&access_token=" + jwt);
        HttpsURLConnection connection = (HttpsURLConnection) zoomTokenEndpoint.openConnection();

        if(connection.getResponseCode() == HttpsURLConnection.HTTP_OK) //I get response code of -1 here
        {
            InputStream responseBody = connection.getInputStream();
            InputStreamReader responseBodyReader = new InputStreamReader(responseBody, "UTF-8");
            BufferedReader streamReader = new BufferedReader(responseBodyReader);
            StringBuilder responseStrBuilder = new StringBuilder();

            //get JSON String
            String inputStr;
            while((inputStr = streamReader.readLine()) != null)
            {
                responseStrBuilder.append(inputStr);
            }
            connection.disconnect();
            JSONObject jsonObject = new JSONObject(responseStrBuilder.toString());
            return jsonObject.getString("token");
        }else {
            System.out.println("Error in connection");;
            return null;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
```

---

<div class="post-metadata">

**Author:** ![junndobit123](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/junndobit123/32/15018_2.png) [@junndobit123](https://devforum.zoom.us/u/junndobit123)\
**Post date:** [September 10, 2020, 3:17pm UTC](https://devforum.zoom.us/t/android-retrieve-zoom-access-token-failure/29760/2 "2020-09-10T15:17:04Z")

</div>

I got it guys. The problem is I’ve used the APP\_KEY and APP\_SECRET to generate the JWT. The one needed to generate the JWT is the API key and API secret. So basically you need 4 constants: App key/ SDK Key, App Secret / and the SDK Secret for initialization, API key, and API secret for the generation of JWT.

 ![zoom sdk and api keys android](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/4/4791898d2674409cf3127baf52ff82ca923a77f5.png)
