anchor.diff:          Proplist = mochijson2:decode(ResponseBody, [{format, proplist}]),
           IdToken = proplists:get_value(<<"id_token">>, Proplist),
           [_Header, Payload, _Signature] = binary:split(IdToken, <<".">>, [global]),
  -        IdTokenProplist = mochijson2:decode(base64decode(Payload), [{format, proplist}]),
  +        IdTokenProplist = mochijson2:decode(mochiweb_base64url:decode(Payload), [{format, proplist}]),
           TokenResponse = #token_response{
               access_token = proplists:get_value(<<"access_token">>, Proplist),
               token_type = proplists:get_value(<<"token_type">>, Proplist),
  
positive.code:         },
          {ok, TokenResponse}
      end).
  
  %% ====================================================================
  %% Internal functions
  %% ====================================================================
  
  %% base64decode/0
  %% ====================================================================
  %% @doc
  %% Decodes a base64 encoded term.
  %% @end
  -spec base64decode(binary() | string()) -> term().
  %% ====================================================================
  base64decode(Bin) when is_binary(Bin) ->
      Bin2 = case byte_size(Bin) rem 4 of
                 2 -> <<Bin/binary, "==">>;
                 3 -> <<Bin/binary, "=">>;
                 _ -> Bin
             end,
      base64:decode(<<<<(urldecode_digit(D))>> || <<D>> <= Bin2>>);
  base64decode(L) when is_list(L) ->
      base64decode(iolist_to_binary(L)).
  
  
  %% urldecode_digit/0
  %% ====================================================================
  %% @doc
  %% Urlencodes a single char in base64.
  %% @end
  -spec urldecode_digit(binary()) -> binary().
  %% ====================================================================
  urldecode_digit($_) -> $/;
  urldecode_digit($-) -> $+;
  urldecode_digit(D) -> D.
  
negative.code: -export([get_client_authorization_code/1, get_client_tokens/1, remove_client_token/2, verify_client/2]).
  -export([get_token_response/2]).
  
  
  %% ====================================================================
  %% API functions
  