All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lajospolya.spotifyapiwrapper.request.PostAuthorizationCodeFlow Maven / Gradle / Ivy

Go to download

This project wraps the Spotify public API in order to allow users to intuitively use it

There is a newer version: 3.0.RELEASE
Show newest version
package com.lajospolya.spotifyapiwrapper.request;

import com.lajospolya.spotifyapiwrapper.body.AuthorizationCode;
import com.lajospolya.spotifyapiwrapper.response.AuthorizingToken;

/**
 * @author Lajos Polya
 *
 * Represents the endpoint at POST https://accounts.spotify.com/api/token as descrbibed at
 * https://developer.spotify.com/documentation/web-api/reference-beta/
 */
public class PostAuthorizationCodeFlow extends AbstractSpotifyRequest
{
    private static final String REQUEST_URI_STRING = "https://accounts.spotify.com/api/token";

    private PostAuthorizationCodeFlow(SpotifyRequestBuilder requestBuilder)
    {
        super(requestBuilder);
    }

    public static class Builder extends AbstractBuilder
    {
        private String code;
        private String redirectUri;

        public Builder(String code, String redirectUri) throws IllegalArgumentException
        {
            spotifyRequestParamValidationService.validateParametersNotNull(code, redirectUri);
            this.code = code;
            this.redirectUri = redirectUri;
        }

        @Override
        public PostAuthorizationCodeFlow build()
        {
            SpotifyRequestBuilder spotifyRequestBuilder = new SpotifyRequestBuilder(REQUEST_URI_STRING);
            spotifyRequestBuilder.contentType(URL_ENCODED_CONTENT_TYPE_HEADER_VALUE);

            return new PostAuthorizationCodeFlow(
                    spotifyRequestBuilder.POSTWithStringBody(
                            new AuthorizationCode(code, redirectUri).toUrlEncodedString()));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy