Comments (3)
NOW, server_key is deprecated on v1.4.3!!
Thank you all!!
@lackneets @ryy
from fcmpush.
I have faced this problem before.
I tried to use access_token
instead of server_key
but it didn't work.
Lines 136 to 141 in 872a528
def legacy_authorized_header(headers)
headers.merge('Content-Type' => 'application/json',
'Accept' => 'application/json',
- 'Authorization' => "Bearer #{server_key}"
+ 'Authorization' => "Bearer #{access_token}")
end
Fcmpush::Unauthorized: Received an error response 401 Unauthorized: <HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
However, I found a way to make subscribe
and unsubscribe
work with access_token
.
Could you please assign this issue to me?
from fcmpush.
Sorry, I'm not sure how to do this. I did not describe the solution.
Add the following to the header
access_token_auth: true
.
ref: https://takanamito.hateblo.jp/entry/2020/07/04/175045
It works.
# config/initializers/monkey_patches.rb
Dir[Rails.root.join('lib', 'monkey_patches', '**', '*.rb')].each do |file|
require file
end
# lib/monkey_patches/fcmpush/client.rb
module FcmPushMonkeyPatch
module Client
private
def legacy_authorized_header(headers)
headers.merge('Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => "Bearer #{access_token}", # <- Change from server_key to access_token
'access_token_auth' => 'true') # <- add new header key value
end
end
end
Fcmpush::Client.prepend(FcmPushMonkeyPatch::Client)
from fcmpush.
Related Issues (11)
- support FCM Batch request for efficiency
- push method and batch_push method error handling compatibility HOT 2
- there is a bug in multiple configuration HOT 2
- configuring json_key_io as StringIO breaks Fcmpush config if google reponds with 403 HOT 2
- Ruby3
- Github Actions - Ruby 3.0.1 HOT 2
- Raise custom error if missing configuration HOT 1
- Sender id mismatch HOT 2
- Configure multiple fcm account HOT 1
- Using fcmpush behind a proxy HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fcmpush.