# Spring Security OAuth2 Behavior

**URL:** <https://discuss.dev.twitch.com/t/spring-security-oauth2-behavior/45534>\
**Category:** API\
**Created:** [May 4, 2023, 2:48pm UTC](https://discuss.dev.twitch.com/t/spring-security-oauth2-behavior/45534 "2023-05-04T14:48:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![datfeelman](https://avatars.discourse-cdn.com/v4/letter/d/fbc32d/32.png) [@datfeelman](https://discuss.dev.twitch.com/u/datfeelman)\
**Post date:** [May 4, 2023, 2:48pm UTC](https://discuss.dev.twitch.com/t/spring-security-oauth2-behavior/45534/1 "2023-05-04T14:48:38Z")

</div>

Good day. I’m trying to use twitch authentication for my pet project.  
The spring framework supports the implementation of the OAUTH2 protocol, you just need to specify the necessary properties and the properties required by the twitch api.  
The problem is that after authenticating on the twitch side, I get into an endless redirect. on this page  
[https://id.twitch.tv/oauth2/authorize?response\_type=code&client\_id=redacted&state=ER3TV5Ff6IBHQEMQ3s4sQUaTlODJTISvrnqkUigT78Y%3D&redirect\_uri=http://localhost:5000](https://id.twitch.tv/oauth2/authorize?response_type=code&client_id=redacted&state=ER3TV5Ff6IBHQEMQ3s4sQUaTlODJTISvrnqkUigT78Y%3D&redirect_uri=http://localhost:5000)  
I also see this error in devtools

```auto
Security Error: Content at https://id.twitch.tv/oauth2/authorize?response_type=code&client_id=redacted&state=osiGYfDpavAKThgeh6X4zIdbhSklnJrFWjuMBYp_69A%3D&redirect_uri=http://localhost:5000/login/oauth2/code/twitch may not load data from blob:https://id.twitch.tv/redacted

```

properties that are set for twitch oauth2 client spring

```auto
spring:
  security:
    oauth2:
      client:
        registration:
          twitch:
            client-id: ${twitch-client-id}
            client-secret: ${twitch-client-secret}
            redirect-uri: http://localhost:5000
            authorization-grant-type: authorization_code
            response-type: code
        provider:
          twitch:
            authorization-uri: https://id.twitch.tv/oauth2/authorize
            token-uri: https://id.twitch.tv/oauth2/token
            user-info-uri: https://api.twitch.tv/helix/users

```

What am I doing wrong? I would be grateful for your help  
P.S.  
I also looked at what the redirect url looks like in google api

```auto
http://localhost:5000/login/oauth2/code/{registration_id} // google, facebook, etc

```

Changing the url does not solve the problem, except that from the side of my application I get errors

```auto
An error occurred reading the OAuth 2.0 Error: errorCode cannot be empty

```

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [June 3, 2023, 2:48pm UTC](https://discuss.dev.twitch.com/t/spring-security-oauth2-behavior/45534/2 "2023-06-03T14:48:46Z")

</div>

Closed on June 3, 2023, 2:48pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
