Magento2 REST auth help needed












3















I'm hanging on this issues for nearly a week and cannot find any sollution. I'm trying to send a REST request to my new Magento2 store. It worked allready, but then the oauth/token forced authentication was activated, now I can't beak through to the backend.
I tried it with the scribe framework v1.8.0, here's my attempt:



public class MagentoApi extends DefaultApi10a {
private static final String BASE_URL = "http://myshopurl.de/";
private static final String AUTHORIZE_URL = "http://myshopurl.de/oauth/oauth_authorize?oauth_token=";
private static final String REQUEST_TOKEN_ENDPOINT = "http://myshopurl.de/oauth/token/request";
private static final String ACCESS_TOKEN_ENDPOINT = "http://myshopurl.de/oauth/token/access";

@Override
public String getAccessTokenEndpoint() {
return ACCESS_TOKEN_ENDPOINT;
}

@Override
public String getRequestTokenEndpoint() {
return REQUEST_TOKEN_ENDPOINT;
}

@Override
public String getAuthorizationUrl(OAuth1RequestToken requestToken) {
return String.format(AUTHORIZE_URL, requestToken.getToken());
}
public static MagentoApi instance() {
return MagentoApi.InstanceHolder.INSTANCE;
}

private static class InstanceHolder {
private static final MagentoApi INSTANCE = new MagentoApi();

private InstanceHolder() {
}
}
}


And here my testclient:



public class AuthTest {

private static final String CONSUMER_KEY = "MYCONSUMERKEYHERE";
private static final String CONSUMER_SECRET = "MYSECRETKEYHERE";


public static void main(String args) throws IOException {
OAuth10aService service = new ServiceBuilder()
.apiKey(CONSUMER_KEY)
.apiSecret(CONSUMER_SECRET)
.debug()
.build(MagentoApi.instance());
final OAuth1RequestToken requestToken = service.getRequestToken();
System.out.println(service.getAuthorizationUrl(requestToken));
final String oauthVerifier = in.nextLine();
final OAuth1AccessToken accessToken = service.getAccessToken(requestToken, oauthVerifier);
final OAuthRequest request = new OAuthRequest(Verb.GET, The_Magento_Get_Categories_REST_URL, service);
service.signRequest(accessToken, request);
final Response response = request.send();
System.out.println(response.getBody());
}
}


The result is appearing in this line:
final OAuth1RequestToken requestToken = service.getRequestToken();



this is the sysout:



Fetching the Request Token...
obtaining request token from http://myshopurl.de/oauth/token/request
setting oauth_callback to oob
generating signature...
using base64 encoder: CommonsCodec
base string is: POST&http%3A%2F%2Fmyshopurl.de%2Foauth%2Ftoken%2Frequest&oauth_callback%3Doob%26oauth_consumer_key%thekey%26oauth_nonce%3D3285773414%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1467397682%26oauth_version%3D1.0
signature is: u4h6pVZw6tU8aj0NdFljBSB3h9o=
appended additional OAuth parameters: { oauth_nonce -> 3285773414 , oauth_signature -> u4h6pVZw6tU8aj0NdFljBSB3h9o= , oauth_callback -> oob , oauth_consumer_key -> thekey, oauth_timestamp -> 1467397682 , oauth_signature_method -> HMAC-SHA1 , oauth_version -> 1.0 }
using Http Header signature
sending request...
response status code: 401
response body: oauth_problem=Consumer+key+has+expired


I'm really begging for help.



Otherwise, is there a possibility to deactivate the authentication via REST at all?



Thank you in advance!



PS: The integration is activated in the backend. I also tried reauthorizing several times.
Integration Authorized










share|improve this question
















bumped to the homepage by Community 16 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    3















    I'm hanging on this issues for nearly a week and cannot find any sollution. I'm trying to send a REST request to my new Magento2 store. It worked allready, but then the oauth/token forced authentication was activated, now I can't beak through to the backend.
    I tried it with the scribe framework v1.8.0, here's my attempt:



    public class MagentoApi extends DefaultApi10a {
    private static final String BASE_URL = "http://myshopurl.de/";
    private static final String AUTHORIZE_URL = "http://myshopurl.de/oauth/oauth_authorize?oauth_token=";
    private static final String REQUEST_TOKEN_ENDPOINT = "http://myshopurl.de/oauth/token/request";
    private static final String ACCESS_TOKEN_ENDPOINT = "http://myshopurl.de/oauth/token/access";

    @Override
    public String getAccessTokenEndpoint() {
    return ACCESS_TOKEN_ENDPOINT;
    }

    @Override
    public String getRequestTokenEndpoint() {
    return REQUEST_TOKEN_ENDPOINT;
    }

    @Override
    public String getAuthorizationUrl(OAuth1RequestToken requestToken) {
    return String.format(AUTHORIZE_URL, requestToken.getToken());
    }
    public static MagentoApi instance() {
    return MagentoApi.InstanceHolder.INSTANCE;
    }

    private static class InstanceHolder {
    private static final MagentoApi INSTANCE = new MagentoApi();

    private InstanceHolder() {
    }
    }
    }


    And here my testclient:



    public class AuthTest {

    private static final String CONSUMER_KEY = "MYCONSUMERKEYHERE";
    private static final String CONSUMER_SECRET = "MYSECRETKEYHERE";


    public static void main(String args) throws IOException {
    OAuth10aService service = new ServiceBuilder()
    .apiKey(CONSUMER_KEY)
    .apiSecret(CONSUMER_SECRET)
    .debug()
    .build(MagentoApi.instance());
    final OAuth1RequestToken requestToken = service.getRequestToken();
    System.out.println(service.getAuthorizationUrl(requestToken));
    final String oauthVerifier = in.nextLine();
    final OAuth1AccessToken accessToken = service.getAccessToken(requestToken, oauthVerifier);
    final OAuthRequest request = new OAuthRequest(Verb.GET, The_Magento_Get_Categories_REST_URL, service);
    service.signRequest(accessToken, request);
    final Response response = request.send();
    System.out.println(response.getBody());
    }
    }


    The result is appearing in this line:
    final OAuth1RequestToken requestToken = service.getRequestToken();



    this is the sysout:



    Fetching the Request Token...
    obtaining request token from http://myshopurl.de/oauth/token/request
    setting oauth_callback to oob
    generating signature...
    using base64 encoder: CommonsCodec
    base string is: POST&http%3A%2F%2Fmyshopurl.de%2Foauth%2Ftoken%2Frequest&oauth_callback%3Doob%26oauth_consumer_key%thekey%26oauth_nonce%3D3285773414%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1467397682%26oauth_version%3D1.0
    signature is: u4h6pVZw6tU8aj0NdFljBSB3h9o=
    appended additional OAuth parameters: { oauth_nonce -> 3285773414 , oauth_signature -> u4h6pVZw6tU8aj0NdFljBSB3h9o= , oauth_callback -> oob , oauth_consumer_key -> thekey, oauth_timestamp -> 1467397682 , oauth_signature_method -> HMAC-SHA1 , oauth_version -> 1.0 }
    using Http Header signature
    sending request...
    response status code: 401
    response body: oauth_problem=Consumer+key+has+expired


    I'm really begging for help.



    Otherwise, is there a possibility to deactivate the authentication via REST at all?



    Thank you in advance!



    PS: The integration is activated in the backend. I also tried reauthorizing several times.
    Integration Authorized










    share|improve this question
















    bumped to the homepage by Community 16 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      3












      3








      3








      I'm hanging on this issues for nearly a week and cannot find any sollution. I'm trying to send a REST request to my new Magento2 store. It worked allready, but then the oauth/token forced authentication was activated, now I can't beak through to the backend.
      I tried it with the scribe framework v1.8.0, here's my attempt:



      public class MagentoApi extends DefaultApi10a {
      private static final String BASE_URL = "http://myshopurl.de/";
      private static final String AUTHORIZE_URL = "http://myshopurl.de/oauth/oauth_authorize?oauth_token=";
      private static final String REQUEST_TOKEN_ENDPOINT = "http://myshopurl.de/oauth/token/request";
      private static final String ACCESS_TOKEN_ENDPOINT = "http://myshopurl.de/oauth/token/access";

      @Override
      public String getAccessTokenEndpoint() {
      return ACCESS_TOKEN_ENDPOINT;
      }

      @Override
      public String getRequestTokenEndpoint() {
      return REQUEST_TOKEN_ENDPOINT;
      }

      @Override
      public String getAuthorizationUrl(OAuth1RequestToken requestToken) {
      return String.format(AUTHORIZE_URL, requestToken.getToken());
      }
      public static MagentoApi instance() {
      return MagentoApi.InstanceHolder.INSTANCE;
      }

      private static class InstanceHolder {
      private static final MagentoApi INSTANCE = new MagentoApi();

      private InstanceHolder() {
      }
      }
      }


      And here my testclient:



      public class AuthTest {

      private static final String CONSUMER_KEY = "MYCONSUMERKEYHERE";
      private static final String CONSUMER_SECRET = "MYSECRETKEYHERE";


      public static void main(String args) throws IOException {
      OAuth10aService service = new ServiceBuilder()
      .apiKey(CONSUMER_KEY)
      .apiSecret(CONSUMER_SECRET)
      .debug()
      .build(MagentoApi.instance());
      final OAuth1RequestToken requestToken = service.getRequestToken();
      System.out.println(service.getAuthorizationUrl(requestToken));
      final String oauthVerifier = in.nextLine();
      final OAuth1AccessToken accessToken = service.getAccessToken(requestToken, oauthVerifier);
      final OAuthRequest request = new OAuthRequest(Verb.GET, The_Magento_Get_Categories_REST_URL, service);
      service.signRequest(accessToken, request);
      final Response response = request.send();
      System.out.println(response.getBody());
      }
      }


      The result is appearing in this line:
      final OAuth1RequestToken requestToken = service.getRequestToken();



      this is the sysout:



      Fetching the Request Token...
      obtaining request token from http://myshopurl.de/oauth/token/request
      setting oauth_callback to oob
      generating signature...
      using base64 encoder: CommonsCodec
      base string is: POST&http%3A%2F%2Fmyshopurl.de%2Foauth%2Ftoken%2Frequest&oauth_callback%3Doob%26oauth_consumer_key%thekey%26oauth_nonce%3D3285773414%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1467397682%26oauth_version%3D1.0
      signature is: u4h6pVZw6tU8aj0NdFljBSB3h9o=
      appended additional OAuth parameters: { oauth_nonce -> 3285773414 , oauth_signature -> u4h6pVZw6tU8aj0NdFljBSB3h9o= , oauth_callback -> oob , oauth_consumer_key -> thekey, oauth_timestamp -> 1467397682 , oauth_signature_method -> HMAC-SHA1 , oauth_version -> 1.0 }
      using Http Header signature
      sending request...
      response status code: 401
      response body: oauth_problem=Consumer+key+has+expired


      I'm really begging for help.



      Otherwise, is there a possibility to deactivate the authentication via REST at all?



      Thank you in advance!



      PS: The integration is activated in the backend. I also tried reauthorizing several times.
      Integration Authorized










      share|improve this question
















      I'm hanging on this issues for nearly a week and cannot find any sollution. I'm trying to send a REST request to my new Magento2 store. It worked allready, but then the oauth/token forced authentication was activated, now I can't beak through to the backend.
      I tried it with the scribe framework v1.8.0, here's my attempt:



      public class MagentoApi extends DefaultApi10a {
      private static final String BASE_URL = "http://myshopurl.de/";
      private static final String AUTHORIZE_URL = "http://myshopurl.de/oauth/oauth_authorize?oauth_token=";
      private static final String REQUEST_TOKEN_ENDPOINT = "http://myshopurl.de/oauth/token/request";
      private static final String ACCESS_TOKEN_ENDPOINT = "http://myshopurl.de/oauth/token/access";

      @Override
      public String getAccessTokenEndpoint() {
      return ACCESS_TOKEN_ENDPOINT;
      }

      @Override
      public String getRequestTokenEndpoint() {
      return REQUEST_TOKEN_ENDPOINT;
      }

      @Override
      public String getAuthorizationUrl(OAuth1RequestToken requestToken) {
      return String.format(AUTHORIZE_URL, requestToken.getToken());
      }
      public static MagentoApi instance() {
      return MagentoApi.InstanceHolder.INSTANCE;
      }

      private static class InstanceHolder {
      private static final MagentoApi INSTANCE = new MagentoApi();

      private InstanceHolder() {
      }
      }
      }


      And here my testclient:



      public class AuthTest {

      private static final String CONSUMER_KEY = "MYCONSUMERKEYHERE";
      private static final String CONSUMER_SECRET = "MYSECRETKEYHERE";


      public static void main(String args) throws IOException {
      OAuth10aService service = new ServiceBuilder()
      .apiKey(CONSUMER_KEY)
      .apiSecret(CONSUMER_SECRET)
      .debug()
      .build(MagentoApi.instance());
      final OAuth1RequestToken requestToken = service.getRequestToken();
      System.out.println(service.getAuthorizationUrl(requestToken));
      final String oauthVerifier = in.nextLine();
      final OAuth1AccessToken accessToken = service.getAccessToken(requestToken, oauthVerifier);
      final OAuthRequest request = new OAuthRequest(Verb.GET, The_Magento_Get_Categories_REST_URL, service);
      service.signRequest(accessToken, request);
      final Response response = request.send();
      System.out.println(response.getBody());
      }
      }


      The result is appearing in this line:
      final OAuth1RequestToken requestToken = service.getRequestToken();



      this is the sysout:



      Fetching the Request Token...
      obtaining request token from http://myshopurl.de/oauth/token/request
      setting oauth_callback to oob
      generating signature...
      using base64 encoder: CommonsCodec
      base string is: POST&http%3A%2F%2Fmyshopurl.de%2Foauth%2Ftoken%2Frequest&oauth_callback%3Doob%26oauth_consumer_key%thekey%26oauth_nonce%3D3285773414%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1467397682%26oauth_version%3D1.0
      signature is: u4h6pVZw6tU8aj0NdFljBSB3h9o=
      appended additional OAuth parameters: { oauth_nonce -> 3285773414 , oauth_signature -> u4h6pVZw6tU8aj0NdFljBSB3h9o= , oauth_callback -> oob , oauth_consumer_key -> thekey, oauth_timestamp -> 1467397682 , oauth_signature_method -> HMAC-SHA1 , oauth_version -> 1.0 }
      using Http Header signature
      sending request...
      response status code: 401
      response body: oauth_problem=Consumer+key+has+expired


      I'm really begging for help.



      Otherwise, is there a possibility to deactivate the authentication via REST at all?



      Thank you in advance!



      PS: The integration is activated in the backend. I also tried reauthorizing several times.
      Integration Authorized







      magento2 rest oauth magento-2.1 integration






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 2 '16 at 7:23







      Java_Waldi

















      asked Jul 1 '16 at 18:36









      Java_WaldiJava_Waldi

      2301212




      2301212





      bumped to the homepage by Community 16 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 16 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          According to the error message your consumer key has expired.



          You need to access your backend under System > Extensions > Integration choose your integration and click Activate



          The full documentation is available here: http://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication-oauth.html






          share|improve this answer
























          • Hello, maybe I needed to say that the integration is activated, I attached a screenshot

            – Java_Waldi
            Jul 1 '16 at 18:52













          • @Java_Waldi yes but the expiration is 300 seconds you may need to re activate the integration

            – Raphael at Digital Pianism
            Jul 1 '16 at 20:53






          • 1





            As I allready mentioned above, I allready tried reauthorizing several times. I Also tried setting the expiration time to 0 or max value. Result was always the same. The documentation is not helpful at all because there is no java exaample given.

            – Java_Waldi
            Jul 2 '16 at 5:35











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f123872%2fmagento2-rest-auth-help-needed%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          According to the error message your consumer key has expired.



          You need to access your backend under System > Extensions > Integration choose your integration and click Activate



          The full documentation is available here: http://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication-oauth.html






          share|improve this answer
























          • Hello, maybe I needed to say that the integration is activated, I attached a screenshot

            – Java_Waldi
            Jul 1 '16 at 18:52













          • @Java_Waldi yes but the expiration is 300 seconds you may need to re activate the integration

            – Raphael at Digital Pianism
            Jul 1 '16 at 20:53






          • 1





            As I allready mentioned above, I allready tried reauthorizing several times. I Also tried setting the expiration time to 0 or max value. Result was always the same. The documentation is not helpful at all because there is no java exaample given.

            – Java_Waldi
            Jul 2 '16 at 5:35
















          0














          According to the error message your consumer key has expired.



          You need to access your backend under System > Extensions > Integration choose your integration and click Activate



          The full documentation is available here: http://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication-oauth.html






          share|improve this answer
























          • Hello, maybe I needed to say that the integration is activated, I attached a screenshot

            – Java_Waldi
            Jul 1 '16 at 18:52













          • @Java_Waldi yes but the expiration is 300 seconds you may need to re activate the integration

            – Raphael at Digital Pianism
            Jul 1 '16 at 20:53






          • 1





            As I allready mentioned above, I allready tried reauthorizing several times. I Also tried setting the expiration time to 0 or max value. Result was always the same. The documentation is not helpful at all because there is no java exaample given.

            – Java_Waldi
            Jul 2 '16 at 5:35














          0












          0








          0







          According to the error message your consumer key has expired.



          You need to access your backend under System > Extensions > Integration choose your integration and click Activate



          The full documentation is available here: http://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication-oauth.html






          share|improve this answer













          According to the error message your consumer key has expired.



          You need to access your backend under System > Extensions > Integration choose your integration and click Activate



          The full documentation is available here: http://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication-oauth.html







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 1 '16 at 18:44









          Raphael at Digital PianismRaphael at Digital Pianism

          53.8k20117271




          53.8k20117271













          • Hello, maybe I needed to say that the integration is activated, I attached a screenshot

            – Java_Waldi
            Jul 1 '16 at 18:52













          • @Java_Waldi yes but the expiration is 300 seconds you may need to re activate the integration

            – Raphael at Digital Pianism
            Jul 1 '16 at 20:53






          • 1





            As I allready mentioned above, I allready tried reauthorizing several times. I Also tried setting the expiration time to 0 or max value. Result was always the same. The documentation is not helpful at all because there is no java exaample given.

            – Java_Waldi
            Jul 2 '16 at 5:35



















          • Hello, maybe I needed to say that the integration is activated, I attached a screenshot

            – Java_Waldi
            Jul 1 '16 at 18:52













          • @Java_Waldi yes but the expiration is 300 seconds you may need to re activate the integration

            – Raphael at Digital Pianism
            Jul 1 '16 at 20:53






          • 1





            As I allready mentioned above, I allready tried reauthorizing several times. I Also tried setting the expiration time to 0 or max value. Result was always the same. The documentation is not helpful at all because there is no java exaample given.

            – Java_Waldi
            Jul 2 '16 at 5:35

















          Hello, maybe I needed to say that the integration is activated, I attached a screenshot

          – Java_Waldi
          Jul 1 '16 at 18:52







          Hello, maybe I needed to say that the integration is activated, I attached a screenshot

          – Java_Waldi
          Jul 1 '16 at 18:52















          @Java_Waldi yes but the expiration is 300 seconds you may need to re activate the integration

          – Raphael at Digital Pianism
          Jul 1 '16 at 20:53





          @Java_Waldi yes but the expiration is 300 seconds you may need to re activate the integration

          – Raphael at Digital Pianism
          Jul 1 '16 at 20:53




          1




          1





          As I allready mentioned above, I allready tried reauthorizing several times. I Also tried setting the expiration time to 0 or max value. Result was always the same. The documentation is not helpful at all because there is no java exaample given.

          – Java_Waldi
          Jul 2 '16 at 5:35





          As I allready mentioned above, I allready tried reauthorizing several times. I Also tried setting the expiration time to 0 or max value. Result was always the same. The documentation is not helpful at all because there is no java exaample given.

          – Java_Waldi
          Jul 2 '16 at 5:35


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f123872%2fmagento2-rest-auth-help-needed%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          What other Star Trek series did the main TNG cast show up in?

          Berlina muro

          Berlina aerponto